# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
273469 | 2020-08-19T05:30:05 Z | 송준혁(#5100) | Exercise Deadlines (CCO20_day1problem2) | C++17 | 3 ms | 384 KB |
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long LL; typedef pair<int,int> pii; int N; LL ans; pii A[202020]; int T[202020]; priority_queue<int> PQ; void upd(int k){for(;k<=N;k+=k&-k)T[k]++;} int read(int k){int r=0; for(;k;k^=k&-k)r+=T[k]; return r;} int main(){ scanf("%d", &N); for (int i=1; i<=N; i++) scanf("%d", &A[i].fi), A[i].se=i; sort(A+1, A+N+1); int t=N; for (int i=N; i>0; i--){ while (t>0 && A[t].fi>=i) PQ.push(A[i].se), t--; if (PQ.empty()){ puts("-1"); return 0; } int x = PQ.top(); PQ.pop(); ans += read(x), upd(x); } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |