# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38213 | antimirage | Money (IZhO17_money) | C++14 | 1500 ms | 52784 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
using namespace std;
const int N = 1e6 + 5;
int n, ar[N], cur, ans, l = 1, pos = 1e9 + 7;
set <int> st;
main ()
{
cin >> n;
for (int i = 1; i <= n; i++)
scanf("%d", &ar[i]);
cur = ar[1];
int i = 1;
while (i <= n)
{
if ( ar[i] < ar[i - 1] || pos < ar[i] )
{
ans++;
cur = ar[i];
while ( l < i )
st.insert(ar[l]), l++;
if (st.lower_bound(cur + 1) == st.end()) pos = 1e9 + 7;
else pos = *st.lower_bound( cur + 1 );
}
i++;
}
cout << ans + 1 << endl;
}
/**
7
1 2 1 2 3 4 5
**/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |