# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91098 | emil_physmath | Money (IZhO17_money) | C++14 | 2 ms | 652 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 <stdio.h>
#include <algorithm>
#include <set>
using namespace std;
int a[1000005];
int main()
{
int n;
cin>>n;
for (int k=0; k<n; k++)
scanf("%d", a+k);
int i=0, ans=0;
set<int> curSorted;
curSorted.insert(0);
while (i<n)
{
ans++;
int j=i;
while (j+1<n && a[j+1]>a[j])
j++;
auto lBound=curSorted.upper_bound(a[i]);
lBound--;
auto rBound=(lBound==curSorted.end()?curSorted.begin():++lBound);
if (rBound!=curSorted.end())
j=upper_bound(a+i, a+j+1, *rBound)-a-1;
for (int k=i; k<=j; k++)
curSorted.insert(a[k]);
i=j+1;
}
cout<<ans<<'\n';
char I;
cin >> I;
return 0;
}
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... |