#include <iostream>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
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;
long long int a[300005], f[300005], g[300005];
int main() {
long long 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 |
2 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
477 ms |
41176 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
36088 KB |
Output is correct |
2 |
Correct |
225 ms |
36176 KB |
Output is correct |
3 |
Correct |
218 ms |
36108 KB |
Output is correct |
4 |
Correct |
219 ms |
36556 KB |
Output is correct |
5 |
Correct |
213 ms |
36208 KB |
Output is correct |
6 |
Correct |
219 ms |
36208 KB |
Output is correct |
7 |
Correct |
245 ms |
36008 KB |
Output is correct |
8 |
Correct |
438 ms |
36200 KB |
Output is correct |
9 |
Correct |
441 ms |
36116 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
36088 KB |
Output is correct |
2 |
Correct |
225 ms |
36176 KB |
Output is correct |
3 |
Correct |
218 ms |
36108 KB |
Output is correct |
4 |
Correct |
219 ms |
36556 KB |
Output is correct |
5 |
Correct |
213 ms |
36208 KB |
Output is correct |
6 |
Correct |
219 ms |
36208 KB |
Output is correct |
7 |
Correct |
245 ms |
36008 KB |
Output is correct |
8 |
Correct |
438 ms |
36200 KB |
Output is correct |
9 |
Correct |
441 ms |
36116 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
364 ms |
36424 KB |
Output is correct |
12 |
Correct |
349 ms |
36432 KB |
Output is correct |
13 |
Correct |
334 ms |
36436 KB |
Output is correct |
14 |
Correct |
339 ms |
36468 KB |
Output is correct |
15 |
Correct |
364 ms |
36432 KB |
Output is correct |
16 |
Correct |
343 ms |
36548 KB |
Output is correct |
17 |
Correct |
356 ms |
36492 KB |
Output is correct |
18 |
Correct |
386 ms |
36272 KB |
Output is correct |
19 |
Correct |
392 ms |
36552 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
36088 KB |
Output is correct |
2 |
Correct |
225 ms |
36176 KB |
Output is correct |
3 |
Correct |
218 ms |
36108 KB |
Output is correct |
4 |
Correct |
219 ms |
36556 KB |
Output is correct |
5 |
Correct |
213 ms |
36208 KB |
Output is correct |
6 |
Correct |
219 ms |
36208 KB |
Output is correct |
7 |
Correct |
245 ms |
36008 KB |
Output is correct |
8 |
Correct |
438 ms |
36200 KB |
Output is correct |
9 |
Correct |
441 ms |
36116 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
364 ms |
36424 KB |
Output is correct |
12 |
Correct |
349 ms |
36432 KB |
Output is correct |
13 |
Correct |
334 ms |
36436 KB |
Output is correct |
14 |
Correct |
339 ms |
36468 KB |
Output is correct |
15 |
Correct |
364 ms |
36432 KB |
Output is correct |
16 |
Correct |
343 ms |
36548 KB |
Output is correct |
17 |
Correct |
356 ms |
36492 KB |
Output is correct |
18 |
Correct |
386 ms |
36272 KB |
Output is correct |
19 |
Correct |
392 ms |
36552 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
470 ms |
37128 KB |
Output is correct |
22 |
Correct |
457 ms |
37140 KB |
Output is correct |
23 |
Correct |
409 ms |
37320 KB |
Output is correct |
24 |
Correct |
405 ms |
37164 KB |
Output is correct |
25 |
Correct |
429 ms |
37256 KB |
Output is correct |
26 |
Correct |
397 ms |
37360 KB |
Output is correct |
27 |
Correct |
473 ms |
37364 KB |
Output is correct |
28 |
Correct |
435 ms |
37156 KB |
Output is correct |
29 |
Correct |
421 ms |
37388 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
477 ms |
41176 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |