# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169170 | itgl | Money (IZhO17_money) | C++14 | 2 ms | 376 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>
#define pb push_back
using namespace std;
int a[1000005];
multiset <int> ms;
int main(){
int n;
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
a[n+1]=-1;
int pos;
for(int i=1;i<=n;i++){
if(a[i+1]>a[i]) ms.insert(a[i]);
else{
pos=i+1;
ms.insert(a[i]);
break;
}
}
ms.insert(1e6+7);
int ans=1;
a[pos-1]=0;
int lim;
while(pos<=n){
lim=*ms.upper_bound(a[pos]);
ans++;
int cnt=1;
for(int i=pos+1;i<=n;i++){
if(a[i]<lim&&a[i-1]<=a[i]){
cnt++;
ms.insert(a[i]);
}
}
pos+=cnt;
}
cout << ans << '\n';
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... |