# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
348840 | 2021-01-15T21:32:52 Z | luciocf | Exercise Deadlines (CCO20_day1problem2) | C++14 | 146 ms | 18408 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5+10; struct FenwickTree { int bit[maxn]; void upd(int x, int v) { for (; x < maxn; x += (x&-x)) bit[x] += v; } int soma(int x) { int ans = 0; for (; x > 0; x -= (x&-x)) ans += bit[x]; return ans; } int get(int l, int r) { return soma(r)-soma(l-1); } } BIT; int a[maxn]; vector<int> lista[maxn]; int main(void) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); lista[x].push_back(i); } set<int> st; for (int i = n; i >= 1; i--) { for (auto p: lista[i]) st.insert(p); if (st.size() == 0) { printf("-1\n"); return 0; } a[i] = *st.rbegin(); st.erase(a[i]); } long long ans = 0; for (int i = 1; i <= n; i++) { ans += 1ll*(BIT.get(a[i], n)); BIT.upd(a[i], 1); } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5228 KB | Output is correct |
2 | Correct | 6 ms | 5228 KB | Output is correct |
3 | Correct | 6 ms | 5228 KB | Output is correct |
4 | Correct | 6 ms | 5228 KB | Output is correct |
5 | Correct | 6 ms | 5228 KB | Output is correct |
6 | Correct | 6 ms | 5228 KB | Output is correct |
7 | Correct | 5 ms | 5228 KB | Output is correct |
8 | Correct | 5 ms | 5228 KB | Output is correct |
9 | Correct | 5 ms | 5228 KB | Output is correct |
10 | Correct | 5 ms | 5228 KB | Output is correct |
11 | Correct | 5 ms | 5228 KB | Output is correct |
12 | Correct | 5 ms | 5228 KB | Output is correct |
13 | Correct | 5 ms | 5228 KB | Output is correct |
14 | Correct | 5 ms | 5376 KB | Output is correct |
15 | Correct | 5 ms | 5228 KB | Output is correct |
16 | Correct | 5 ms | 5228 KB | Output is correct |
17 | Correct | 5 ms | 5228 KB | Output is correct |
18 | Correct | 5 ms | 5228 KB | Output is correct |
19 | Correct | 5 ms | 5228 KB | Output is correct |
20 | Correct | 5 ms | 5228 KB | Output is correct |
21 | Correct | 5 ms | 5228 KB | Output is correct |
22 | Correct | 5 ms | 5228 KB | Output is correct |
23 | Correct | 6 ms | 5228 KB | Output is correct |
24 | Correct | 7 ms | 5228 KB | Output is correct |
25 | Correct | 5 ms | 5228 KB | Output is correct |
26 | Correct | 6 ms | 5228 KB | Output is correct |
27 | Correct | 5 ms | 5228 KB | Output is correct |
28 | Correct | 6 ms | 5228 KB | Output is correct |
29 | Correct | 6 ms | 5228 KB | Output is correct |
30 | Correct | 5 ms | 5228 KB | Output is correct |
31 | Correct | 5 ms | 5228 KB | Output is correct |
32 | Correct | 5 ms | 5356 KB | Output is correct |
33 | Correct | 5 ms | 5228 KB | Output is correct |
34 | Correct | 5 ms | 5228 KB | Output is correct |
35 | Correct | 5 ms | 5228 KB | Output is correct |
36 | Correct | 6 ms | 5356 KB | Output is correct |
37 | Correct | 5 ms | 5228 KB | Output is correct |
38 | Correct | 5 ms | 5228 KB | Output is correct |
39 | Correct | 6 ms | 5228 KB | Output is correct |
40 | Correct | 6 ms | 5228 KB | Output is correct |
41 | Correct | 5 ms | 5100 KB | Output is correct |
42 | Correct | 6 ms | 5228 KB | Output is correct |
43 | Correct | 5 ms | 5100 KB | Output is correct |
44 | Correct | 4 ms | 5100 KB | Output is correct |
45 | Correct | 4 ms | 4972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5228 KB | Output is correct |
2 | Correct | 6 ms | 5228 KB | Output is correct |
3 | Correct | 6 ms | 5228 KB | Output is correct |
4 | Correct | 6 ms | 5228 KB | Output is correct |
5 | Correct | 6 ms | 5228 KB | Output is correct |
6 | Correct | 6 ms | 5228 KB | Output is correct |
7 | Correct | 5 ms | 5228 KB | Output is correct |
8 | Correct | 5 ms | 5228 KB | Output is correct |
9 | Correct | 5 ms | 5228 KB | Output is correct |
10 | Correct | 5 ms | 5228 KB | Output is correct |
11 | Correct | 5 ms | 5228 KB | Output is correct |
12 | Correct | 5 ms | 5228 KB | Output is correct |
13 | Correct | 5 ms | 5228 KB | Output is correct |
14 | Correct | 5 ms | 5376 KB | Output is correct |
15 | Correct | 5 ms | 5228 KB | Output is correct |
16 | Correct | 5 ms | 5228 KB | Output is correct |
17 | Correct | 5 ms | 5228 KB | Output is correct |
18 | Correct | 5 ms | 5228 KB | Output is correct |
19 | Correct | 5 ms | 5228 KB | Output is correct |
20 | Correct | 5 ms | 5228 KB | Output is correct |
21 | Correct | 5 ms | 5228 KB | Output is correct |
22 | Correct | 5 ms | 5228 KB | Output is correct |
23 | Correct | 6 ms | 5228 KB | Output is correct |
24 | Correct | 7 ms | 5228 KB | Output is correct |
25 | Correct | 5 ms | 5228 KB | Output is correct |
26 | Correct | 6 ms | 5228 KB | Output is correct |
27 | Correct | 5 ms | 5228 KB | Output is correct |
28 | Correct | 6 ms | 5228 KB | Output is correct |
29 | Correct | 6 ms | 5228 KB | Output is correct |
30 | Correct | 5 ms | 5228 KB | Output is correct |
31 | Correct | 5 ms | 5228 KB | Output is correct |
32 | Correct | 5 ms | 5356 KB | Output is correct |
33 | Correct | 5 ms | 5228 KB | Output is correct |
34 | Correct | 5 ms | 5228 KB | Output is correct |
35 | Correct | 5 ms | 5228 KB | Output is correct |
36 | Correct | 6 ms | 5356 KB | Output is correct |
37 | Correct | 5 ms | 5228 KB | Output is correct |
38 | Correct | 5 ms | 5228 KB | Output is correct |
39 | Correct | 6 ms | 5228 KB | Output is correct |
40 | Correct | 6 ms | 5228 KB | Output is correct |
41 | Correct | 5 ms | 5100 KB | Output is correct |
42 | Correct | 6 ms | 5228 KB | Output is correct |
43 | Correct | 5 ms | 5100 KB | Output is correct |
44 | Correct | 4 ms | 5100 KB | Output is correct |
45 | Correct | 4 ms | 4972 KB | Output is correct |
46 | Correct | 146 ms | 14692 KB | Output is correct |
47 | Correct | 138 ms | 14572 KB | Output is correct |
48 | Correct | 125 ms | 14700 KB | Output is correct |
49 | Correct | 125 ms | 14592 KB | Output is correct |
50 | Correct | 129 ms | 14700 KB | Output is correct |
51 | Correct | 124 ms | 14572 KB | Output is correct |
52 | Correct | 101 ms | 14060 KB | Output is correct |
53 | Correct | 100 ms | 14060 KB | Output is correct |
54 | Correct | 81 ms | 14052 KB | Output is correct |
55 | Correct | 62 ms | 14060 KB | Output is correct |
56 | Correct | 72 ms | 14060 KB | Output is correct |
57 | Correct | 77 ms | 14060 KB | Output is correct |
58 | Correct | 96 ms | 11884 KB | Output is correct |
59 | Correct | 104 ms | 12012 KB | Output is correct |
60 | Correct | 94 ms | 11904 KB | Output is correct |
61 | Correct | 81 ms | 11884 KB | Output is correct |
62 | Correct | 67 ms | 11884 KB | Output is correct |
63 | Correct | 82 ms | 11884 KB | Output is correct |
64 | Correct | 105 ms | 11884 KB | Output is correct |
65 | Correct | 103 ms | 11972 KB | Output is correct |
66 | Correct | 98 ms | 11884 KB | Output is correct |
67 | Correct | 89 ms | 11884 KB | Output is correct |
68 | Correct | 106 ms | 11884 KB | Output is correct |
69 | Correct | 104 ms | 11884 KB | Output is correct |
70 | Correct | 112 ms | 12652 KB | Output is correct |
71 | Correct | 117 ms | 12652 KB | Output is correct |
72 | Correct | 121 ms | 12652 KB | Output is correct |
73 | Correct | 120 ms | 12936 KB | Output is correct |
74 | Correct | 97 ms | 12780 KB | Output is correct |
75 | Correct | 114 ms | 12720 KB | Output is correct |
76 | Correct | 84 ms | 10988 KB | Output is correct |
77 | Correct | 106 ms | 18152 KB | Output is correct |
78 | Correct | 58 ms | 14060 KB | Output is correct |
79 | Correct | 64 ms | 11884 KB | Output is correct |
80 | Correct | 100 ms | 11884 KB | Output is correct |
81 | Correct | 103 ms | 18408 KB | Output is correct |
82 | Correct | 61 ms | 14060 KB | Output is correct |
83 | Correct | 64 ms | 12012 KB | Output is correct |
84 | Correct | 126 ms | 13804 KB | Output is correct |
85 | Correct | 126 ms | 13804 KB | Output is correct |
86 | Correct | 128 ms | 13804 KB | Output is correct |
87 | Correct | 61 ms | 9964 KB | Output is correct |
88 | Correct | 124 ms | 13804 KB | Output is correct |