Submission #60417

#TimeUsernameProblemLanguageResultExecution timeMemory
60417TenuunMoney (IZhO17_money)C++17
9 / 100
7 ms4512 KiB
#include<bits/stdc++.h> using namespace std; int tr[1000001]; void update(int ind, int val){ while(ind<=1000000){ tr[ind]+=val; ind+=ind&-ind; } } int get(int ind){ int ans=0; while(ind){ ans+=tr[ind]; ind-=ind&-ind; } return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); memset(tr, 0, sizeof tr); int n, last=0, res=1, x, start=0, cnt=1; cin >> n; for(int i=0; i<n; i++){ cin >> x; if(x<last || (abs(x-start)>1 && get(x-1)-get(start)>cnt-1)) { res++; start=x; cnt=1; //cout << i << " "; } else cnt++; last=x; update(x, 1); } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...