# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
273471 | 2020-08-19T05:31:30 Z | 송준혁(#5100) | Exercise Deadlines (CCO20_day1problem2) | C++17 | 106 ms | 4972 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[t].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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 424 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 412 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 416 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 416 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 512 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 3 ms | 384 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 512 KB | Output is correct |
42 | Correct | 2 ms | 384 KB | Output is correct |
43 | Correct | 2 ms | 416 KB | Output is correct |
44 | Correct | 0 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 424 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 412 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 416 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 416 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 512 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 3 ms | 384 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 512 KB | Output is correct |
42 | Correct | 2 ms | 384 KB | Output is correct |
43 | Correct | 2 ms | 416 KB | Output is correct |
44 | Correct | 0 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 88 ms | 4464 KB | Output is correct |
47 | Correct | 87 ms | 4464 KB | Output is correct |
48 | Correct | 77 ms | 4464 KB | Output is correct |
49 | Correct | 79 ms | 4464 KB | Output is correct |
50 | Correct | 101 ms | 4460 KB | Output is correct |
51 | Correct | 81 ms | 4492 KB | Output is correct |
52 | Correct | 63 ms | 3960 KB | Output is correct |
53 | Correct | 63 ms | 3976 KB | Output is correct |
54 | Correct | 54 ms | 3960 KB | Output is correct |
55 | Correct | 44 ms | 4088 KB | Output is correct |
56 | Correct | 68 ms | 3964 KB | Output is correct |
57 | Correct | 57 ms | 3960 KB | Output is correct |
58 | Correct | 80 ms | 4088 KB | Output is correct |
59 | Correct | 79 ms | 3960 KB | Output is correct |
60 | Correct | 70 ms | 3936 KB | Output is correct |
61 | Correct | 60 ms | 3960 KB | Output is correct |
62 | Correct | 52 ms | 3960 KB | Output is correct |
63 | Correct | 62 ms | 3960 KB | Output is correct |
64 | Correct | 75 ms | 3960 KB | Output is correct |
65 | Correct | 87 ms | 3960 KB | Output is correct |
66 | Correct | 83 ms | 4088 KB | Output is correct |
67 | Correct | 75 ms | 3960 KB | Output is correct |
68 | Correct | 106 ms | 3932 KB | Output is correct |
69 | Correct | 79 ms | 4088 KB | Output is correct |
70 | Correct | 102 ms | 4232 KB | Output is correct |
71 | Correct | 84 ms | 4216 KB | Output is correct |
72 | Correct | 82 ms | 4216 KB | Output is correct |
73 | Correct | 101 ms | 4204 KB | Output is correct |
74 | Correct | 64 ms | 4216 KB | Output is correct |
75 | Correct | 83 ms | 4244 KB | Output is correct |
76 | Correct | 72 ms | 4216 KB | Output is correct |
77 | Correct | 82 ms | 4972 KB | Output is correct |
78 | Correct | 48 ms | 4004 KB | Output is correct |
79 | Correct | 53 ms | 3960 KB | Output is correct |
80 | Correct | 75 ms | 4212 KB | Output is correct |
81 | Correct | 105 ms | 4948 KB | Output is correct |
82 | Correct | 47 ms | 3960 KB | Output is correct |
83 | Correct | 51 ms | 3960 KB | Output is correct |
84 | Correct | 86 ms | 4340 KB | Output is correct |
85 | Correct | 87 ms | 4340 KB | Output is correct |
86 | Correct | 87 ms | 4340 KB | Output is correct |
87 | Correct | 56 ms | 3192 KB | Output is correct |
88 | Correct | 87 ms | 4268 KB | Output is correct |