#include <iostream>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define int long long
namespace __gnu_pbds{
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
int a[300005], f[300005], g[300005];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, res = 0;
cin >> n;
ordered_set s, t;
for (int i = 1; i <= n; i++) {
cin >> a[i];
f[i] = s.order_of_key(a[i]);
s.insert(a[i]);
}
for (int i = n; i >= 1; i--) {
g[i] = t.order_of_key(a[i]);
t.insert(a[i]);
res += f[i] * g[i];
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
487 ms |
44880 KB |
Output is correct |
3 |
Correct |
488 ms |
45136 KB |
Output is correct |
4 |
Correct |
488 ms |
45116 KB |
Output is correct |
5 |
Correct |
490 ms |
44904 KB |
Output is correct |
6 |
Correct |
486 ms |
45088 KB |
Output is correct |
7 |
Correct |
493 ms |
45104 KB |
Output is correct |
8 |
Correct |
492 ms |
44984 KB |
Output is correct |
9 |
Correct |
352 ms |
44880 KB |
Output is correct |
10 |
Correct |
355 ms |
44944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
44884 KB |
Output is correct |
2 |
Correct |
219 ms |
45280 KB |
Output is correct |
3 |
Correct |
210 ms |
44884 KB |
Output is correct |
4 |
Correct |
212 ms |
44884 KB |
Output is correct |
5 |
Correct |
219 ms |
45136 KB |
Output is correct |
6 |
Correct |
214 ms |
45048 KB |
Output is correct |
7 |
Correct |
208 ms |
44884 KB |
Output is correct |
8 |
Correct |
382 ms |
44932 KB |
Output is correct |
9 |
Correct |
387 ms |
44908 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
44884 KB |
Output is correct |
2 |
Correct |
219 ms |
45280 KB |
Output is correct |
3 |
Correct |
210 ms |
44884 KB |
Output is correct |
4 |
Correct |
212 ms |
44884 KB |
Output is correct |
5 |
Correct |
219 ms |
45136 KB |
Output is correct |
6 |
Correct |
214 ms |
45048 KB |
Output is correct |
7 |
Correct |
208 ms |
44884 KB |
Output is correct |
8 |
Correct |
382 ms |
44932 KB |
Output is correct |
9 |
Correct |
387 ms |
44908 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
341 ms |
44884 KB |
Output is correct |
12 |
Correct |
413 ms |
44976 KB |
Output is correct |
13 |
Correct |
368 ms |
45060 KB |
Output is correct |
14 |
Correct |
365 ms |
44860 KB |
Output is correct |
15 |
Correct |
364 ms |
44912 KB |
Output is correct |
16 |
Correct |
349 ms |
44880 KB |
Output is correct |
17 |
Correct |
377 ms |
45052 KB |
Output is correct |
18 |
Correct |
321 ms |
44912 KB |
Output is correct |
19 |
Correct |
342 ms |
44988 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
8 ms |
5720 KB |
Output is correct |
12 |
Correct |
8 ms |
5720 KB |
Output is correct |
13 |
Correct |
8 ms |
5720 KB |
Output is correct |
14 |
Correct |
8 ms |
5724 KB |
Output is correct |
15 |
Correct |
8 ms |
5804 KB |
Output is correct |
16 |
Correct |
8 ms |
5724 KB |
Output is correct |
17 |
Correct |
8 ms |
5724 KB |
Output is correct |
18 |
Correct |
8 ms |
5720 KB |
Output is correct |
19 |
Correct |
7 ms |
5724 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
44884 KB |
Output is correct |
2 |
Correct |
219 ms |
45280 KB |
Output is correct |
3 |
Correct |
210 ms |
44884 KB |
Output is correct |
4 |
Correct |
212 ms |
44884 KB |
Output is correct |
5 |
Correct |
219 ms |
45136 KB |
Output is correct |
6 |
Correct |
214 ms |
45048 KB |
Output is correct |
7 |
Correct |
208 ms |
44884 KB |
Output is correct |
8 |
Correct |
382 ms |
44932 KB |
Output is correct |
9 |
Correct |
387 ms |
44908 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
341 ms |
44884 KB |
Output is correct |
12 |
Correct |
413 ms |
44976 KB |
Output is correct |
13 |
Correct |
368 ms |
45060 KB |
Output is correct |
14 |
Correct |
365 ms |
44860 KB |
Output is correct |
15 |
Correct |
364 ms |
44912 KB |
Output is correct |
16 |
Correct |
349 ms |
44880 KB |
Output is correct |
17 |
Correct |
377 ms |
45052 KB |
Output is correct |
18 |
Correct |
321 ms |
44912 KB |
Output is correct |
19 |
Correct |
342 ms |
44988 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
488 ms |
44832 KB |
Output is correct |
22 |
Correct |
404 ms |
45000 KB |
Output is correct |
23 |
Correct |
495 ms |
45060 KB |
Output is correct |
24 |
Correct |
430 ms |
45048 KB |
Output is correct |
25 |
Correct |
387 ms |
44952 KB |
Output is correct |
26 |
Correct |
466 ms |
44852 KB |
Output is correct |
27 |
Correct |
478 ms |
44968 KB |
Output is correct |
28 |
Correct |
355 ms |
44996 KB |
Output is correct |
29 |
Correct |
342 ms |
44808 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
487 ms |
44880 KB |
Output is correct |
3 |
Correct |
488 ms |
45136 KB |
Output is correct |
4 |
Correct |
488 ms |
45116 KB |
Output is correct |
5 |
Correct |
490 ms |
44904 KB |
Output is correct |
6 |
Correct |
486 ms |
45088 KB |
Output is correct |
7 |
Correct |
493 ms |
45104 KB |
Output is correct |
8 |
Correct |
492 ms |
44984 KB |
Output is correct |
9 |
Correct |
352 ms |
44880 KB |
Output is correct |
10 |
Correct |
355 ms |
44944 KB |
Output is correct |
11 |
Correct |
209 ms |
44884 KB |
Output is correct |
12 |
Correct |
219 ms |
45280 KB |
Output is correct |
13 |
Correct |
210 ms |
44884 KB |
Output is correct |
14 |
Correct |
212 ms |
44884 KB |
Output is correct |
15 |
Correct |
219 ms |
45136 KB |
Output is correct |
16 |
Correct |
214 ms |
45048 KB |
Output is correct |
17 |
Correct |
208 ms |
44884 KB |
Output is correct |
18 |
Correct |
382 ms |
44932 KB |
Output is correct |
19 |
Correct |
387 ms |
44908 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
341 ms |
44884 KB |
Output is correct |
22 |
Correct |
413 ms |
44976 KB |
Output is correct |
23 |
Correct |
368 ms |
45060 KB |
Output is correct |
24 |
Correct |
365 ms |
44860 KB |
Output is correct |
25 |
Correct |
364 ms |
44912 KB |
Output is correct |
26 |
Correct |
349 ms |
44880 KB |
Output is correct |
27 |
Correct |
377 ms |
45052 KB |
Output is correct |
28 |
Correct |
321 ms |
44912 KB |
Output is correct |
29 |
Correct |
342 ms |
44988 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
2 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
4444 KB |
Output is correct |
34 |
Correct |
1 ms |
4444 KB |
Output is correct |
35 |
Correct |
1 ms |
4696 KB |
Output is correct |
36 |
Correct |
1 ms |
4444 KB |
Output is correct |
37 |
Correct |
1 ms |
4444 KB |
Output is correct |
38 |
Correct |
1 ms |
4444 KB |
Output is correct |
39 |
Correct |
1 ms |
4440 KB |
Output is correct |
40 |
Correct |
1 ms |
4440 KB |
Output is correct |
41 |
Correct |
8 ms |
5720 KB |
Output is correct |
42 |
Correct |
8 ms |
5720 KB |
Output is correct |
43 |
Correct |
8 ms |
5720 KB |
Output is correct |
44 |
Correct |
8 ms |
5724 KB |
Output is correct |
45 |
Correct |
8 ms |
5804 KB |
Output is correct |
46 |
Correct |
8 ms |
5724 KB |
Output is correct |
47 |
Correct |
8 ms |
5724 KB |
Output is correct |
48 |
Correct |
8 ms |
5720 KB |
Output is correct |
49 |
Correct |
7 ms |
5724 KB |
Output is correct |
50 |
Correct |
1 ms |
4444 KB |
Output is correct |
51 |
Correct |
488 ms |
44832 KB |
Output is correct |
52 |
Correct |
404 ms |
45000 KB |
Output is correct |
53 |
Correct |
495 ms |
45060 KB |
Output is correct |
54 |
Correct |
430 ms |
45048 KB |
Output is correct |
55 |
Correct |
387 ms |
44952 KB |
Output is correct |
56 |
Correct |
466 ms |
44852 KB |
Output is correct |
57 |
Correct |
478 ms |
44968 KB |
Output is correct |
58 |
Correct |
355 ms |
44996 KB |
Output is correct |
59 |
Correct |
342 ms |
44808 KB |
Output is correct |
60 |
Correct |
1 ms |
4440 KB |
Output is correct |
61 |
Correct |
452 ms |
45044 KB |
Output is correct |
62 |
Correct |
429 ms |
45152 KB |
Output is correct |
63 |
Correct |
415 ms |
44880 KB |
Output is correct |
64 |
Correct |
434 ms |
45052 KB |
Output is correct |
65 |
Correct |
458 ms |
45048 KB |
Output is correct |
66 |
Correct |
394 ms |
45056 KB |
Output is correct |
67 |
Correct |
456 ms |
44864 KB |
Output is correct |
68 |
Correct |
414 ms |
44964 KB |
Output is correct |
69 |
Correct |
403 ms |
45036 KB |
Output is correct |
70 |
Correct |
1 ms |
4444 KB |
Output is correct |