# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416300 | Runtime_error_ | Money (IZhO17_money) | C++14 | 1374 ms | 51400 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 <bits/stdc++.h>
using namespace std;
const int inf = 1e6+9;
int n,ans,a[inf];
set<int> s;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",a+i);
int pt = 1;
while(pt <= n){
int mn = inf,mx = 0,i,pre = 0;
for(i=pt;i<=n;i++){
if(a[i] < pre)
break;
mn = min(mn,a[i]);
mx = max(mx,a[i]);
pre = a[i];
if(s.empty() || *s.begin() >= mx || *s.rbegin() <= mn || *s.upper_bound(mn) >= mx)
continue;
break;
}
ans++;
for(int j=pt;j<i;j++)
s.insert(a[j]);
pt = i;
}
printf("%d\n",ans);
}
/*
4
1 4 2 5
6
3 6 4 5 1 2
*/
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... |