# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1092794 | 2024-09-25T06:17:38 Z | Sunbae | Mountains (NOI20_mountains) | C++17 | 160 ms | 14188 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int N = 3e5 + 5; ll a[N], cp[N], A[N], tot; int m, n, bit[N]; int qry(int i){ int r = 0; for(; i; i-=i&-i) r += bit[i]; return r;} void upd(int i){ for(; i<=m; i+=i&-i) ++bit[i];} int pos(ll x){ return upper_bound(cp, cp+m, x) - cp;} signed main(){ scanf("%d", &n); for(int i = 0; i<n; ++i) scanf("%lld", a+i), cp[m++] = a[i]; sort(cp, cp+m); m = unique(cp, cp+m) - cp; for(int i = 0, j; i<n; ++i) A[i] = qry((j = pos(a[i]))-1), upd(j); memset(bit, 0, sizeof(bit)); for(int i = n-1, j; i>=0; --i) tot += A[i] *= qry((j = pos(a[i]))-1), upd(j); printf("%lld", tot); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1628 KB | Output is correct |
2 | Correct | 78 ms | 13980 KB | Output is correct |
3 | Correct | 73 ms | 14160 KB | Output is correct |
4 | Correct | 73 ms | 13964 KB | Output is correct |
5 | Correct | 75 ms | 14164 KB | Output is correct |
6 | Correct | 73 ms | 14160 KB | Output is correct |
7 | Correct | 74 ms | 14132 KB | Output is correct |
8 | Correct | 77 ms | 14164 KB | Output is correct |
9 | Correct | 69 ms | 14188 KB | Output is correct |
10 | Correct | 70 ms | 13964 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 9148 KB | Output is correct |
2 | Correct | 29 ms | 9156 KB | Output is correct |
3 | Correct | 27 ms | 9052 KB | Output is correct |
4 | Correct | 28 ms | 9040 KB | Output is correct |
5 | Correct | 27 ms | 9052 KB | Output is correct |
6 | Correct | 27 ms | 9040 KB | Output is correct |
7 | Correct | 30 ms | 8972 KB | Output is correct |
8 | Correct | 23 ms | 9040 KB | Output is correct |
9 | Correct | 22 ms | 9036 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 9148 KB | Output is correct |
2 | Correct | 29 ms | 9156 KB | Output is correct |
3 | Correct | 27 ms | 9052 KB | Output is correct |
4 | Correct | 28 ms | 9040 KB | Output is correct |
5 | Correct | 27 ms | 9052 KB | Output is correct |
6 | Correct | 27 ms | 9040 KB | Output is correct |
7 | Correct | 30 ms | 8972 KB | Output is correct |
8 | Correct | 23 ms | 9040 KB | Output is correct |
9 | Correct | 22 ms | 9036 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 50 ms | 9476 KB | Output is correct |
12 | Correct | 50 ms | 9296 KB | Output is correct |
13 | Correct | 50 ms | 9296 KB | Output is correct |
14 | Correct | 55 ms | 9300 KB | Output is correct |
15 | Correct | 52 ms | 9296 KB | Output is correct |
16 | Correct | 50 ms | 9300 KB | Output is correct |
17 | Correct | 50 ms | 9296 KB | Output is correct |
18 | Correct | 26 ms | 9296 KB | Output is correct |
19 | Correct | 27 ms | 9368 KB | Output is correct |
20 | Correct | 1 ms | 1624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1628 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1628 KB | Output is correct |
5 | Correct | 1 ms | 1628 KB | Output is correct |
6 | Correct | 1 ms | 1628 KB | Output is correct |
7 | Correct | 1 ms | 1628 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1628 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1628 KB | Output is correct |
5 | Correct | 1 ms | 1628 KB | Output is correct |
6 | Correct | 1 ms | 1628 KB | Output is correct |
7 | Correct | 1 ms | 1628 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1464 KB | Output is correct |
11 | Correct | 4 ms | 1880 KB | Output is correct |
12 | Correct | 4 ms | 1884 KB | Output is correct |
13 | Correct | 4 ms | 1884 KB | Output is correct |
14 | Correct | 4 ms | 1820 KB | Output is correct |
15 | Correct | 5 ms | 2024 KB | Output is correct |
16 | Correct | 4 ms | 1884 KB | Output is correct |
17 | Correct | 4 ms | 1884 KB | Output is correct |
18 | Correct | 4 ms | 2024 KB | Output is correct |
19 | Correct | 3 ms | 1676 KB | Output is correct |
20 | Correct | 1 ms | 1628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 9148 KB | Output is correct |
2 | Correct | 29 ms | 9156 KB | Output is correct |
3 | Correct | 27 ms | 9052 KB | Output is correct |
4 | Correct | 28 ms | 9040 KB | Output is correct |
5 | Correct | 27 ms | 9052 KB | Output is correct |
6 | Correct | 27 ms | 9040 KB | Output is correct |
7 | Correct | 30 ms | 8972 KB | Output is correct |
8 | Correct | 23 ms | 9040 KB | Output is correct |
9 | Correct | 22 ms | 9036 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 50 ms | 9476 KB | Output is correct |
12 | Correct | 50 ms | 9296 KB | Output is correct |
13 | Correct | 50 ms | 9296 KB | Output is correct |
14 | Correct | 55 ms | 9300 KB | Output is correct |
15 | Correct | 52 ms | 9296 KB | Output is correct |
16 | Correct | 50 ms | 9300 KB | Output is correct |
17 | Correct | 50 ms | 9296 KB | Output is correct |
18 | Correct | 26 ms | 9296 KB | Output is correct |
19 | Correct | 27 ms | 9368 KB | Output is correct |
20 | Correct | 1 ms | 1624 KB | Output is correct |
21 | Correct | 122 ms | 10324 KB | Output is correct |
22 | Correct | 123 ms | 10360 KB | Output is correct |
23 | Correct | 120 ms | 10320 KB | Output is correct |
24 | Correct | 126 ms | 10612 KB | Output is correct |
25 | Correct | 120 ms | 10320 KB | Output is correct |
26 | Correct | 120 ms | 10320 KB | Output is correct |
27 | Correct | 120 ms | 10144 KB | Output is correct |
28 | Correct | 48 ms | 10324 KB | Output is correct |
29 | Correct | 48 ms | 10324 KB | Output is correct |
30 | Correct | 1 ms | 1628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1628 KB | Output is correct |
2 | Correct | 78 ms | 13980 KB | Output is correct |
3 | Correct | 73 ms | 14160 KB | Output is correct |
4 | Correct | 73 ms | 13964 KB | Output is correct |
5 | Correct | 75 ms | 14164 KB | Output is correct |
6 | Correct | 73 ms | 14160 KB | Output is correct |
7 | Correct | 74 ms | 14132 KB | Output is correct |
8 | Correct | 77 ms | 14164 KB | Output is correct |
9 | Correct | 69 ms | 14188 KB | Output is correct |
10 | Correct | 70 ms | 13964 KB | Output is correct |
11 | Correct | 39 ms | 9148 KB | Output is correct |
12 | Correct | 29 ms | 9156 KB | Output is correct |
13 | Correct | 27 ms | 9052 KB | Output is correct |
14 | Correct | 28 ms | 9040 KB | Output is correct |
15 | Correct | 27 ms | 9052 KB | Output is correct |
16 | Correct | 27 ms | 9040 KB | Output is correct |
17 | Correct | 30 ms | 8972 KB | Output is correct |
18 | Correct | 23 ms | 9040 KB | Output is correct |
19 | Correct | 22 ms | 9036 KB | Output is correct |
20 | Correct | 1 ms | 1628 KB | Output is correct |
21 | Correct | 50 ms | 9476 KB | Output is correct |
22 | Correct | 50 ms | 9296 KB | Output is correct |
23 | Correct | 50 ms | 9296 KB | Output is correct |
24 | Correct | 55 ms | 9300 KB | Output is correct |
25 | Correct | 52 ms | 9296 KB | Output is correct |
26 | Correct | 50 ms | 9300 KB | Output is correct |
27 | Correct | 50 ms | 9296 KB | Output is correct |
28 | Correct | 26 ms | 9296 KB | Output is correct |
29 | Correct | 27 ms | 9368 KB | Output is correct |
30 | Correct | 1 ms | 1624 KB | Output is correct |
31 | Correct | 1 ms | 1628 KB | Output is correct |
32 | Correct | 1 ms | 1628 KB | Output is correct |
33 | Correct | 1 ms | 1628 KB | Output is correct |
34 | Correct | 1 ms | 1628 KB | Output is correct |
35 | Correct | 1 ms | 1628 KB | Output is correct |
36 | Correct | 1 ms | 1628 KB | Output is correct |
37 | Correct | 1 ms | 1628 KB | Output is correct |
38 | Correct | 1 ms | 1628 KB | Output is correct |
39 | Correct | 1 ms | 1628 KB | Output is correct |
40 | Correct | 1 ms | 1464 KB | Output is correct |
41 | Correct | 4 ms | 1880 KB | Output is correct |
42 | Correct | 4 ms | 1884 KB | Output is correct |
43 | Correct | 4 ms | 1884 KB | Output is correct |
44 | Correct | 4 ms | 1820 KB | Output is correct |
45 | Correct | 5 ms | 2024 KB | Output is correct |
46 | Correct | 4 ms | 1884 KB | Output is correct |
47 | Correct | 4 ms | 1884 KB | Output is correct |
48 | Correct | 4 ms | 2024 KB | Output is correct |
49 | Correct | 3 ms | 1676 KB | Output is correct |
50 | Correct | 1 ms | 1628 KB | Output is correct |
51 | Correct | 122 ms | 10324 KB | Output is correct |
52 | Correct | 123 ms | 10360 KB | Output is correct |
53 | Correct | 120 ms | 10320 KB | Output is correct |
54 | Correct | 126 ms | 10612 KB | Output is correct |
55 | Correct | 120 ms | 10320 KB | Output is correct |
56 | Correct | 120 ms | 10320 KB | Output is correct |
57 | Correct | 120 ms | 10144 KB | Output is correct |
58 | Correct | 48 ms | 10324 KB | Output is correct |
59 | Correct | 48 ms | 10324 KB | Output is correct |
60 | Correct | 1 ms | 1628 KB | Output is correct |
61 | Correct | 153 ms | 14172 KB | Output is correct |
62 | Correct | 154 ms | 14136 KB | Output is correct |
63 | Correct | 156 ms | 14096 KB | Output is correct |
64 | Correct | 152 ms | 14080 KB | Output is correct |
65 | Correct | 160 ms | 14160 KB | Output is correct |
66 | Correct | 160 ms | 14164 KB | Output is correct |
67 | Correct | 158 ms | 13948 KB | Output is correct |
68 | Correct | 147 ms | 14016 KB | Output is correct |
69 | Correct | 126 ms | 10284 KB | Output is correct |
70 | Correct | 1 ms | 1624 KB | Output is correct |