# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
308740 | 2020-10-01T19:24:49 Z | NintsiChkhaidze | Exercise Deadlines (CCO20_day1problem2) | C++14 | 121 ms | 13432 KB |
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define left (node<<1),l,((l+r)>>1) #define right ((node<<1)|1),((l+r)>>1) + 1,r #define N 200001 #define ll long long using namespace std; priority_queue <int> q; int fen[200005]; vector <int> v[200005]; void upd(int in,int val){ while (in < N){ fen[in]+=val; in += (in&(-in)); } } int get(int in){ int sum=0; while (in > 0){ sum+=fen[in]; in -= (in&(-in)); } return sum; } int main(){ int n; scanf("%d",&n); for (int i=1;i<=n;i++){ int a; scanf("%d",&a); v[a].pb(i); } int ind = n; ll ans = 0; while (ind > 0){ for (int i = 0; i < v[ind].size(); i++) q.push(v[ind][i]); if (q.size() == 0) {ans=-1; break;} int x = q.top() - get(q.top()); ans+=ind - x; upd(q.top(),1); q.pop(); ind--; } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5120 KB | Output is correct |
2 | Correct | 5 ms | 5120 KB | Output is correct |
3 | Correct | 5 ms | 5120 KB | Output is correct |
4 | Correct | 5 ms | 5120 KB | Output is correct |
5 | Correct | 5 ms | 5120 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 5 ms | 5248 KB | Output is correct |
9 | Correct | 5 ms | 5248 KB | Output is correct |
10 | Correct | 5 ms | 5248 KB | Output is correct |
11 | Correct | 5 ms | 5248 KB | Output is correct |
12 | Correct | 6 ms | 5248 KB | Output is correct |
13 | Correct | 5 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 5 ms | 5120 KB | Output is correct |
16 | Correct | 5 ms | 5120 KB | Output is correct |
17 | Correct | 5 ms | 5120 KB | Output is correct |
18 | Correct | 5 ms | 5120 KB | Output is correct |
19 | Correct | 5 ms | 5120 KB | Output is correct |
20 | Correct | 5 ms | 5120 KB | Output is correct |
21 | Correct | 5 ms | 5120 KB | Output is correct |
22 | Correct | 5 ms | 5120 KB | Output is correct |
23 | Correct | 6 ms | 5120 KB | Output is correct |
24 | Correct | 5 ms | 5120 KB | Output is correct |
25 | Correct | 5 ms | 5120 KB | Output is correct |
26 | Correct | 6 ms | 5120 KB | Output is correct |
27 | Correct | 5 ms | 5120 KB | Output is correct |
28 | Correct | 6 ms | 5120 KB | Output is correct |
29 | Correct | 5 ms | 5120 KB | Output is correct |
30 | Correct | 5 ms | 5120 KB | Output is correct |
31 | Correct | 5 ms | 5120 KB | Output is correct |
32 | Correct | 5 ms | 5120 KB | Output is correct |
33 | Correct | 5 ms | 5248 KB | Output is correct |
34 | Correct | 5 ms | 5120 KB | Output is correct |
35 | Correct | 6 ms | 5176 KB | Output is correct |
36 | Correct | 5 ms | 5248 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5120 KB | Output is correct |
39 | Correct | 6 ms | 5120 KB | Output is correct |
40 | Correct | 5 ms | 5120 KB | Output is correct |
41 | Correct | 5 ms | 5120 KB | Output is correct |
42 | Correct | 5 ms | 5120 KB | Output is correct |
43 | Correct | 5 ms | 5120 KB | Output is correct |
44 | Correct | 3 ms | 4992 KB | Output is correct |
45 | Correct | 3 ms | 5024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5120 KB | Output is correct |
2 | Correct | 5 ms | 5120 KB | Output is correct |
3 | Correct | 5 ms | 5120 KB | Output is correct |
4 | Correct | 5 ms | 5120 KB | Output is correct |
5 | Correct | 5 ms | 5120 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 5 ms | 5248 KB | Output is correct |
9 | Correct | 5 ms | 5248 KB | Output is correct |
10 | Correct | 5 ms | 5248 KB | Output is correct |
11 | Correct | 5 ms | 5248 KB | Output is correct |
12 | Correct | 6 ms | 5248 KB | Output is correct |
13 | Correct | 5 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 5 ms | 5120 KB | Output is correct |
16 | Correct | 5 ms | 5120 KB | Output is correct |
17 | Correct | 5 ms | 5120 KB | Output is correct |
18 | Correct | 5 ms | 5120 KB | Output is correct |
19 | Correct | 5 ms | 5120 KB | Output is correct |
20 | Correct | 5 ms | 5120 KB | Output is correct |
21 | Correct | 5 ms | 5120 KB | Output is correct |
22 | Correct | 5 ms | 5120 KB | Output is correct |
23 | Correct | 6 ms | 5120 KB | Output is correct |
24 | Correct | 5 ms | 5120 KB | Output is correct |
25 | Correct | 5 ms | 5120 KB | Output is correct |
26 | Correct | 6 ms | 5120 KB | Output is correct |
27 | Correct | 5 ms | 5120 KB | Output is correct |
28 | Correct | 6 ms | 5120 KB | Output is correct |
29 | Correct | 5 ms | 5120 KB | Output is correct |
30 | Correct | 5 ms | 5120 KB | Output is correct |
31 | Correct | 5 ms | 5120 KB | Output is correct |
32 | Correct | 5 ms | 5120 KB | Output is correct |
33 | Correct | 5 ms | 5248 KB | Output is correct |
34 | Correct | 5 ms | 5120 KB | Output is correct |
35 | Correct | 6 ms | 5176 KB | Output is correct |
36 | Correct | 5 ms | 5248 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5120 KB | Output is correct |
39 | Correct | 6 ms | 5120 KB | Output is correct |
40 | Correct | 5 ms | 5120 KB | Output is correct |
41 | Correct | 5 ms | 5120 KB | Output is correct |
42 | Correct | 5 ms | 5120 KB | Output is correct |
43 | Correct | 5 ms | 5120 KB | Output is correct |
44 | Correct | 3 ms | 4992 KB | Output is correct |
45 | Correct | 3 ms | 5024 KB | Output is correct |
46 | Correct | 107 ms | 9456 KB | Output is correct |
47 | Correct | 109 ms | 10868 KB | Output is correct |
48 | Correct | 98 ms | 10864 KB | Output is correct |
49 | Correct | 99 ms | 10740 KB | Output is correct |
50 | Correct | 98 ms | 10740 KB | Output is correct |
51 | Correct | 95 ms | 10740 KB | Output is correct |
52 | Correct | 108 ms | 13304 KB | Output is correct |
53 | Correct | 99 ms | 13432 KB | Output is correct |
54 | Correct | 81 ms | 13332 KB | Output is correct |
55 | Correct | 62 ms | 13288 KB | Output is correct |
56 | Correct | 81 ms | 13304 KB | Output is correct |
57 | Correct | 87 ms | 13304 KB | Output is correct |
58 | Correct | 96 ms | 11256 KB | Output is correct |
59 | Correct | 104 ms | 11128 KB | Output is correct |
60 | Correct | 93 ms | 11128 KB | Output is correct |
61 | Correct | 84 ms | 11128 KB | Output is correct |
62 | Correct | 65 ms | 11128 KB | Output is correct |
63 | Correct | 88 ms | 11256 KB | Output is correct |
64 | Correct | 106 ms | 11000 KB | Output is correct |
65 | Correct | 109 ms | 11004 KB | Output is correct |
66 | Correct | 96 ms | 11000 KB | Output is correct |
67 | Correct | 87 ms | 11128 KB | Output is correct |
68 | Correct | 97 ms | 11128 KB | Output is correct |
69 | Correct | 111 ms | 11000 KB | Output is correct |
70 | Correct | 112 ms | 11032 KB | Output is correct |
71 | Correct | 114 ms | 10932 KB | Output is correct |
72 | Correct | 104 ms | 11004 KB | Output is correct |
73 | Correct | 102 ms | 11000 KB | Output is correct |
74 | Correct | 77 ms | 11000 KB | Output is correct |
75 | Correct | 102 ms | 11000 KB | Output is correct |
76 | Correct | 81 ms | 10616 KB | Output is correct |
77 | Correct | 69 ms | 8992 KB | Output is correct |
78 | Correct | 57 ms | 13304 KB | Output is correct |
79 | Correct | 63 ms | 11128 KB | Output is correct |
80 | Correct | 94 ms | 10744 KB | Output is correct |
81 | Correct | 69 ms | 9088 KB | Output is correct |
82 | Correct | 55 ms | 13304 KB | Output is correct |
83 | Correct | 60 ms | 11128 KB | Output is correct |
84 | Correct | 110 ms | 10996 KB | Output is correct |
85 | Correct | 112 ms | 10996 KB | Output is correct |
86 | Correct | 121 ms | 11008 KB | Output is correct |
87 | Correct | 72 ms | 9976 KB | Output is correct |
88 | Correct | 107 ms | 11084 KB | Output is correct |