# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545171 | krit3379 | Money (IZhO17_money) | C++17 | 1073 ms | 58092 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;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 1000005
int a[N],ma,ans;
set<int> s;
int main(){
int n,i;
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%d",&a[i]);
s.insert(N);
ma=N;
ans=1;
for(i=1;i<=n;i++){
if(a[i]==a[i-1])continue;
auto it=s.lower_bound(a[i]);
if(a[i]<a[i-1]||ma!=*it){
ans++;
ma=*s.upper_bound(a[i]);
}
s.insert(a[i]);
}
printf("%d",ans);
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... |