# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341451 | katearima | Money (IZhO17_money) | C++14 | 1457 ms | 58220 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 N=1e6+5;
int n,t,ans, a[N], mn,mx;
set <int> st;
set<int>::iterator itr;
main(){
cin>>n;
mn=1e6+4;
for(int i=0; i<n; i++){
cin>>a[i];
mx=max(mx, a[i]);
mn=min(mn, a[i]);
}
mn--; mx++;
//cout<<mn<<" "<<mx<<endl;
st.insert(mn); st.insert(mx);
for(int i=0; i<n; i++){
bool tr=false;
st.insert(a[i]);
int k=*st.upper_bound(a[i]);
while(a[i]<=a[i+1] && a[i+1]<=k){
st.insert(a[i+1]);
i++;
tr=true;
}
//if(tr) i--;
//cout<<i<<" "<<a[i]<<endl;
ans++;
}
cout<<ans<<endl;
}
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... |