#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() {
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
961 ms |
45200 KB |
Output is correct |
3 |
Correct |
918 ms |
50488 KB |
Output is correct |
4 |
Correct |
964 ms |
50416 KB |
Output is correct |
5 |
Correct |
929 ms |
50516 KB |
Output is correct |
6 |
Correct |
960 ms |
50576 KB |
Output is correct |
7 |
Correct |
971 ms |
50348 KB |
Output is correct |
8 |
Correct |
944 ms |
50516 KB |
Output is correct |
9 |
Correct |
629 ms |
50548 KB |
Output is correct |
10 |
Correct |
642 ms |
50460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
45028 KB |
Output is correct |
2 |
Correct |
280 ms |
45092 KB |
Output is correct |
3 |
Correct |
238 ms |
44896 KB |
Output is correct |
4 |
Correct |
231 ms |
44884 KB |
Output is correct |
5 |
Correct |
263 ms |
44996 KB |
Output is correct |
6 |
Correct |
239 ms |
44884 KB |
Output is correct |
7 |
Correct |
227 ms |
44880 KB |
Output is correct |
8 |
Correct |
594 ms |
44784 KB |
Output is correct |
9 |
Correct |
582 ms |
45056 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
45028 KB |
Output is correct |
2 |
Correct |
280 ms |
45092 KB |
Output is correct |
3 |
Correct |
238 ms |
44896 KB |
Output is correct |
4 |
Correct |
231 ms |
44884 KB |
Output is correct |
5 |
Correct |
263 ms |
44996 KB |
Output is correct |
6 |
Correct |
239 ms |
44884 KB |
Output is correct |
7 |
Correct |
227 ms |
44880 KB |
Output is correct |
8 |
Correct |
594 ms |
44784 KB |
Output is correct |
9 |
Correct |
582 ms |
45056 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
369 ms |
45048 KB |
Output is correct |
12 |
Correct |
389 ms |
45028 KB |
Output is correct |
13 |
Correct |
383 ms |
44900 KB |
Output is correct |
14 |
Correct |
349 ms |
45008 KB |
Output is correct |
15 |
Correct |
438 ms |
45036 KB |
Output is correct |
16 |
Correct |
366 ms |
44892 KB |
Output is correct |
17 |
Correct |
359 ms |
45076 KB |
Output is correct |
18 |
Correct |
524 ms |
44988 KB |
Output is correct |
19 |
Correct |
511 ms |
44856 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4548 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
2 ms |
4544 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4452 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4548 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
2 ms |
4544 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4452 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
11 ms |
5828 KB |
Output is correct |
12 |
Correct |
11 ms |
5992 KB |
Output is correct |
13 |
Correct |
11 ms |
6056 KB |
Output is correct |
14 |
Correct |
11 ms |
5980 KB |
Output is correct |
15 |
Correct |
11 ms |
5980 KB |
Output is correct |
16 |
Correct |
11 ms |
6024 KB |
Output is correct |
17 |
Correct |
11 ms |
5980 KB |
Output is correct |
18 |
Correct |
11 ms |
5980 KB |
Output is correct |
19 |
Correct |
8 ms |
5724 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
45028 KB |
Output is correct |
2 |
Correct |
280 ms |
45092 KB |
Output is correct |
3 |
Correct |
238 ms |
44896 KB |
Output is correct |
4 |
Correct |
231 ms |
44884 KB |
Output is correct |
5 |
Correct |
263 ms |
44996 KB |
Output is correct |
6 |
Correct |
239 ms |
44884 KB |
Output is correct |
7 |
Correct |
227 ms |
44880 KB |
Output is correct |
8 |
Correct |
594 ms |
44784 KB |
Output is correct |
9 |
Correct |
582 ms |
45056 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
369 ms |
45048 KB |
Output is correct |
12 |
Correct |
389 ms |
45028 KB |
Output is correct |
13 |
Correct |
383 ms |
44900 KB |
Output is correct |
14 |
Correct |
349 ms |
45008 KB |
Output is correct |
15 |
Correct |
438 ms |
45036 KB |
Output is correct |
16 |
Correct |
366 ms |
44892 KB |
Output is correct |
17 |
Correct |
359 ms |
45076 KB |
Output is correct |
18 |
Correct |
524 ms |
44988 KB |
Output is correct |
19 |
Correct |
511 ms |
44856 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
454 ms |
44984 KB |
Output is correct |
22 |
Correct |
583 ms |
45068 KB |
Output is correct |
23 |
Correct |
446 ms |
44880 KB |
Output is correct |
24 |
Correct |
512 ms |
44884 KB |
Output is correct |
25 |
Correct |
522 ms |
44988 KB |
Output is correct |
26 |
Correct |
479 ms |
44880 KB |
Output is correct |
27 |
Correct |
453 ms |
44880 KB |
Output is correct |
28 |
Correct |
550 ms |
44872 KB |
Output is correct |
29 |
Correct |
541 ms |
44868 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
961 ms |
45200 KB |
Output is correct |
3 |
Correct |
918 ms |
50488 KB |
Output is correct |
4 |
Correct |
964 ms |
50416 KB |
Output is correct |
5 |
Correct |
929 ms |
50516 KB |
Output is correct |
6 |
Correct |
960 ms |
50576 KB |
Output is correct |
7 |
Correct |
971 ms |
50348 KB |
Output is correct |
8 |
Correct |
944 ms |
50516 KB |
Output is correct |
9 |
Correct |
629 ms |
50548 KB |
Output is correct |
10 |
Correct |
642 ms |
50460 KB |
Output is correct |
11 |
Correct |
235 ms |
45028 KB |
Output is correct |
12 |
Correct |
280 ms |
45092 KB |
Output is correct |
13 |
Correct |
238 ms |
44896 KB |
Output is correct |
14 |
Correct |
231 ms |
44884 KB |
Output is correct |
15 |
Correct |
263 ms |
44996 KB |
Output is correct |
16 |
Correct |
239 ms |
44884 KB |
Output is correct |
17 |
Correct |
227 ms |
44880 KB |
Output is correct |
18 |
Correct |
594 ms |
44784 KB |
Output is correct |
19 |
Correct |
582 ms |
45056 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
369 ms |
45048 KB |
Output is correct |
22 |
Correct |
389 ms |
45028 KB |
Output is correct |
23 |
Correct |
383 ms |
44900 KB |
Output is correct |
24 |
Correct |
349 ms |
45008 KB |
Output is correct |
25 |
Correct |
438 ms |
45036 KB |
Output is correct |
26 |
Correct |
366 ms |
44892 KB |
Output is correct |
27 |
Correct |
359 ms |
45076 KB |
Output is correct |
28 |
Correct |
524 ms |
44988 KB |
Output is correct |
29 |
Correct |
511 ms |
44856 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
1 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
2 ms |
4444 KB |
Output is correct |
34 |
Correct |
1 ms |
4548 KB |
Output is correct |
35 |
Correct |
1 ms |
4440 KB |
Output is correct |
36 |
Correct |
2 ms |
4544 KB |
Output is correct |
37 |
Correct |
1 ms |
4440 KB |
Output is correct |
38 |
Correct |
1 ms |
4444 KB |
Output is correct |
39 |
Correct |
1 ms |
4452 KB |
Output is correct |
40 |
Correct |
1 ms |
4444 KB |
Output is correct |
41 |
Correct |
11 ms |
5828 KB |
Output is correct |
42 |
Correct |
11 ms |
5992 KB |
Output is correct |
43 |
Correct |
11 ms |
6056 KB |
Output is correct |
44 |
Correct |
11 ms |
5980 KB |
Output is correct |
45 |
Correct |
11 ms |
5980 KB |
Output is correct |
46 |
Correct |
11 ms |
6024 KB |
Output is correct |
47 |
Correct |
11 ms |
5980 KB |
Output is correct |
48 |
Correct |
11 ms |
5980 KB |
Output is correct |
49 |
Correct |
8 ms |
5724 KB |
Output is correct |
50 |
Correct |
1 ms |
4440 KB |
Output is correct |
51 |
Correct |
454 ms |
44984 KB |
Output is correct |
52 |
Correct |
583 ms |
45068 KB |
Output is correct |
53 |
Correct |
446 ms |
44880 KB |
Output is correct |
54 |
Correct |
512 ms |
44884 KB |
Output is correct |
55 |
Correct |
522 ms |
44988 KB |
Output is correct |
56 |
Correct |
479 ms |
44880 KB |
Output is correct |
57 |
Correct |
453 ms |
44880 KB |
Output is correct |
58 |
Correct |
550 ms |
44872 KB |
Output is correct |
59 |
Correct |
541 ms |
44868 KB |
Output is correct |
60 |
Correct |
1 ms |
4444 KB |
Output is correct |
61 |
Correct |
572 ms |
50388 KB |
Output is correct |
62 |
Correct |
539 ms |
50552 KB |
Output is correct |
63 |
Correct |
551 ms |
50568 KB |
Output is correct |
64 |
Correct |
555 ms |
50408 KB |
Output is correct |
65 |
Correct |
494 ms |
50428 KB |
Output is correct |
66 |
Correct |
556 ms |
50576 KB |
Output is correct |
67 |
Correct |
504 ms |
50444 KB |
Output is correct |
68 |
Correct |
580 ms |
50540 KB |
Output is correct |
69 |
Correct |
454 ms |
46872 KB |
Output is correct |
70 |
Correct |
1 ms |
4440 KB |
Output is correct |