# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
329921 | 2020-11-23T06:45:48 Z | M_W | Mountains (NOI20_mountains) | C++14 | 1016 ms | 32864 KB |
#include <bits/stdc++.h> using namespace std; map<long long, int> mp; long long a[300300], b[300300]; int fwt[300300]; void add(int v){ for(;v <= 300300; v += (v & -v)) fwt[v]++; } int query(int v){ int ret = 0; for(;v > 0; v -= (v & -v)){ ret += fwt[v]; } return ret; } int main(){ int N; scanf("%d", &N); for(int i = 0; i < N; i++){ scanf("%lld", &a[i]); b[i] = a[i]; } sort(a, a + N); int k = 1; for(int i = 0; i < N; i++){ if(mp[a[i]] == 0) mp[a[i]] = k++; } vector<int> l; for(int i = 0; i < N; i++){ l.push_back(query(mp[b[i]] - 1)); add(mp[b[i]]); } memset(fwt, 0, sizeof fwt); long long ans = 0; for(int i = N - 1; i >= 0; i--){ ans += (query(mp[b[i]] - 1) * 1ll * l[i] * 1ll) * 1ll; add(mp[b[i]]); } printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 352 ms | 27104 KB | Output is correct |
3 | Correct | 345 ms | 26976 KB | Output is correct |
4 | Correct | 353 ms | 26976 KB | Output is correct |
5 | Correct | 345 ms | 26976 KB | Output is correct |
6 | Correct | 347 ms | 26976 KB | Output is correct |
7 | Correct | 347 ms | 26976 KB | Output is correct |
8 | Correct | 348 ms | 26976 KB | Output is correct |
9 | Correct | 284 ms | 17508 KB | Output is correct |
10 | Correct | 286 ms | 17528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 7516 KB | Output is correct |
2 | Correct | 70 ms | 8028 KB | Output is correct |
3 | Correct | 69 ms | 8028 KB | Output is correct |
4 | Correct | 69 ms | 8028 KB | Output is correct |
5 | Correct | 70 ms | 8156 KB | Output is correct |
6 | Correct | 70 ms | 8072 KB | Output is correct |
7 | Correct | 68 ms | 8156 KB | Output is correct |
8 | Correct | 68 ms | 8024 KB | Output is correct |
9 | Correct | 64 ms | 8028 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 7516 KB | Output is correct |
2 | Correct | 70 ms | 8028 KB | Output is correct |
3 | Correct | 69 ms | 8028 KB | Output is correct |
4 | Correct | 69 ms | 8028 KB | Output is correct |
5 | Correct | 70 ms | 8156 KB | Output is correct |
6 | Correct | 70 ms | 8072 KB | Output is correct |
7 | Correct | 68 ms | 8156 KB | Output is correct |
8 | Correct | 68 ms | 8024 KB | Output is correct |
9 | Correct | 64 ms | 8028 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 113 ms | 8412 KB | Output is correct |
12 | Correct | 104 ms | 8412 KB | Output is correct |
13 | Correct | 104 ms | 8412 KB | Output is correct |
14 | Correct | 103 ms | 8452 KB | Output is correct |
15 | Correct | 105 ms | 8412 KB | Output is correct |
16 | Correct | 113 ms | 8412 KB | Output is correct |
17 | Correct | 103 ms | 8348 KB | Output is correct |
18 | Correct | 71 ms | 8308 KB | Output is correct |
19 | Correct | 82 ms | 8412 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1548 KB | Output is correct |
2 | Correct | 2 ms | 1516 KB | Output is correct |
3 | Correct | 1 ms | 1516 KB | Output is correct |
4 | Correct | 2 ms | 1516 KB | Output is correct |
5 | Correct | 2 ms | 1516 KB | Output is correct |
6 | Correct | 2 ms | 1516 KB | Output is correct |
7 | Correct | 2 ms | 1516 KB | Output is correct |
8 | Correct | 1 ms | 1516 KB | Output is correct |
9 | Correct | 2 ms | 1516 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1548 KB | Output is correct |
2 | Correct | 2 ms | 1516 KB | Output is correct |
3 | Correct | 1 ms | 1516 KB | Output is correct |
4 | Correct | 2 ms | 1516 KB | Output is correct |
5 | Correct | 2 ms | 1516 KB | Output is correct |
6 | Correct | 2 ms | 1516 KB | Output is correct |
7 | Correct | 2 ms | 1516 KB | Output is correct |
8 | Correct | 1 ms | 1516 KB | Output is correct |
9 | Correct | 2 ms | 1516 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 13 ms | 2412 KB | Output is correct |
12 | Correct | 15 ms | 2432 KB | Output is correct |
13 | Correct | 13 ms | 2412 KB | Output is correct |
14 | Correct | 13 ms | 2412 KB | Output is correct |
15 | Correct | 13 ms | 2412 KB | Output is correct |
16 | Correct | 14 ms | 2412 KB | Output is correct |
17 | Correct | 13 ms | 2412 KB | Output is correct |
18 | Correct | 11 ms | 2028 KB | Output is correct |
19 | Correct | 6 ms | 1772 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 7516 KB | Output is correct |
2 | Correct | 70 ms | 8028 KB | Output is correct |
3 | Correct | 69 ms | 8028 KB | Output is correct |
4 | Correct | 69 ms | 8028 KB | Output is correct |
5 | Correct | 70 ms | 8156 KB | Output is correct |
6 | Correct | 70 ms | 8072 KB | Output is correct |
7 | Correct | 68 ms | 8156 KB | Output is correct |
8 | Correct | 68 ms | 8024 KB | Output is correct |
9 | Correct | 64 ms | 8028 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 113 ms | 8412 KB | Output is correct |
12 | Correct | 104 ms | 8412 KB | Output is correct |
13 | Correct | 104 ms | 8412 KB | Output is correct |
14 | Correct | 103 ms | 8452 KB | Output is correct |
15 | Correct | 105 ms | 8412 KB | Output is correct |
16 | Correct | 113 ms | 8412 KB | Output is correct |
17 | Correct | 103 ms | 8348 KB | Output is correct |
18 | Correct | 71 ms | 8308 KB | Output is correct |
19 | Correct | 82 ms | 8412 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
21 | Correct | 578 ms | 15336 KB | Output is correct |
22 | Correct | 623 ms | 15208 KB | Output is correct |
23 | Correct | 573 ms | 15328 KB | Output is correct |
24 | Correct | 592 ms | 15352 KB | Output is correct |
25 | Correct | 588 ms | 15380 KB | Output is correct |
26 | Correct | 592 ms | 15336 KB | Output is correct |
27 | Correct | 569 ms | 15456 KB | Output is correct |
28 | Correct | 222 ms | 15168 KB | Output is correct |
29 | Correct | 218 ms | 15208 KB | Output is correct |
30 | Correct | 1 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 352 ms | 27104 KB | Output is correct |
3 | Correct | 345 ms | 26976 KB | Output is correct |
4 | Correct | 353 ms | 26976 KB | Output is correct |
5 | Correct | 345 ms | 26976 KB | Output is correct |
6 | Correct | 347 ms | 26976 KB | Output is correct |
7 | Correct | 347 ms | 26976 KB | Output is correct |
8 | Correct | 348 ms | 26976 KB | Output is correct |
9 | Correct | 284 ms | 17508 KB | Output is correct |
10 | Correct | 286 ms | 17528 KB | Output is correct |
11 | Correct | 70 ms | 7516 KB | Output is correct |
12 | Correct | 70 ms | 8028 KB | Output is correct |
13 | Correct | 69 ms | 8028 KB | Output is correct |
14 | Correct | 69 ms | 8028 KB | Output is correct |
15 | Correct | 70 ms | 8156 KB | Output is correct |
16 | Correct | 70 ms | 8072 KB | Output is correct |
17 | Correct | 68 ms | 8156 KB | Output is correct |
18 | Correct | 68 ms | 8024 KB | Output is correct |
19 | Correct | 64 ms | 8028 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
21 | Correct | 113 ms | 8412 KB | Output is correct |
22 | Correct | 104 ms | 8412 KB | Output is correct |
23 | Correct | 104 ms | 8412 KB | Output is correct |
24 | Correct | 103 ms | 8452 KB | Output is correct |
25 | Correct | 105 ms | 8412 KB | Output is correct |
26 | Correct | 113 ms | 8412 KB | Output is correct |
27 | Correct | 103 ms | 8348 KB | Output is correct |
28 | Correct | 71 ms | 8308 KB | Output is correct |
29 | Correct | 82 ms | 8412 KB | Output is correct |
30 | Correct | 1 ms | 1516 KB | Output is correct |
31 | Correct | 2 ms | 1548 KB | Output is correct |
32 | Correct | 2 ms | 1516 KB | Output is correct |
33 | Correct | 1 ms | 1516 KB | Output is correct |
34 | Correct | 2 ms | 1516 KB | Output is correct |
35 | Correct | 2 ms | 1516 KB | Output is correct |
36 | Correct | 2 ms | 1516 KB | Output is correct |
37 | Correct | 2 ms | 1516 KB | Output is correct |
38 | Correct | 1 ms | 1516 KB | Output is correct |
39 | Correct | 2 ms | 1516 KB | Output is correct |
40 | Correct | 1 ms | 1516 KB | Output is correct |
41 | Correct | 13 ms | 2412 KB | Output is correct |
42 | Correct | 15 ms | 2432 KB | Output is correct |
43 | Correct | 13 ms | 2412 KB | Output is correct |
44 | Correct | 13 ms | 2412 KB | Output is correct |
45 | Correct | 13 ms | 2412 KB | Output is correct |
46 | Correct | 14 ms | 2412 KB | Output is correct |
47 | Correct | 13 ms | 2412 KB | Output is correct |
48 | Correct | 11 ms | 2028 KB | Output is correct |
49 | Correct | 6 ms | 1772 KB | Output is correct |
50 | Correct | 1 ms | 1516 KB | Output is correct |
51 | Correct | 578 ms | 15336 KB | Output is correct |
52 | Correct | 623 ms | 15208 KB | Output is correct |
53 | Correct | 573 ms | 15328 KB | Output is correct |
54 | Correct | 592 ms | 15352 KB | Output is correct |
55 | Correct | 588 ms | 15380 KB | Output is correct |
56 | Correct | 592 ms | 15336 KB | Output is correct |
57 | Correct | 569 ms | 15456 KB | Output is correct |
58 | Correct | 222 ms | 15168 KB | Output is correct |
59 | Correct | 218 ms | 15208 KB | Output is correct |
60 | Correct | 1 ms | 1516 KB | Output is correct |
61 | Correct | 993 ms | 32864 KB | Output is correct |
62 | Correct | 975 ms | 32736 KB | Output is correct |
63 | Correct | 1016 ms | 32864 KB | Output is correct |
64 | Correct | 1010 ms | 32736 KB | Output is correct |
65 | Correct | 1006 ms | 32736 KB | Output is correct |
66 | Correct | 997 ms | 32736 KB | Output is correct |
67 | Correct | 999 ms | 32736 KB | Output is correct |
68 | Correct | 788 ms | 23280 KB | Output is correct |
69 | Correct | 704 ms | 17764 KB | Output is correct |
70 | Correct | 1 ms | 1516 KB | Output is correct |