# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308993 | 2020-10-02T14:26:54 Z | giorgigagua2006 | Exercise Deadlines (CCO20_day1problem2) | C++17 | 8 ms | 5504 KB |
#include<bits/stdc++.h> using namespace std; long long f[12312],n=12312,p,k; priority_queue<long long>q; void upd(int i, int value) { while(i<n) { f[i]+=value; i+=(i & -i); } } int sum(int i) { int s=0; while(i) { s+=f[i]; i-=(i & -i); } return s; } long long i,j,mx,ans; long long d[223123]; vector<long long>v[213213]; int main() { cin>>n; for(i=1;i<=n;i++) { cin>>d[i]; v[d[i]].push_back(i); } for(i=n;i>0;i--) { for(j=0;j<v[i].size();j++) q.push(v[i][j]); if(q.size()==0) { cout<<-1; return 0; } mx=q.top(); q.pop(); upd(n-mx+1,1); ans+=sum(n-mx+1); } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |