#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
#define int long long
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a[n+1];
for(int i=1; i<=n; i++) cin >> a[i];
ost left, right;
for(int i=3; i<=n; i++) right.insert(a[i]);
left.insert(a[1]);
int ans = left.order_of_key(a[2]) * right.order_of_key(a[2]);
for(int i=3; i<n; i++) {
left.insert(a[i-1]);
right.erase(a[i]);
ans += left.order_of_key(a[i]) * right.order_of_key(a[i]);
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
510 ms |
26984 KB |
Output is correct |
3 |
Correct |
523 ms |
27096 KB |
Output is correct |
4 |
Correct |
512 ms |
26980 KB |
Output is correct |
5 |
Correct |
515 ms |
26968 KB |
Output is correct |
6 |
Correct |
535 ms |
26964 KB |
Output is correct |
7 |
Correct |
516 ms |
26948 KB |
Output is correct |
8 |
Correct |
505 ms |
26972 KB |
Output is correct |
9 |
Correct |
303 ms |
17944 KB |
Output is correct |
10 |
Correct |
320 ms |
17952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
3232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
3232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
3232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
510 ms |
26984 KB |
Output is correct |
3 |
Correct |
523 ms |
27096 KB |
Output is correct |
4 |
Correct |
512 ms |
26980 KB |
Output is correct |
5 |
Correct |
515 ms |
26968 KB |
Output is correct |
6 |
Correct |
535 ms |
26964 KB |
Output is correct |
7 |
Correct |
516 ms |
26948 KB |
Output is correct |
8 |
Correct |
505 ms |
26972 KB |
Output is correct |
9 |
Correct |
303 ms |
17944 KB |
Output is correct |
10 |
Correct |
320 ms |
17952 KB |
Output is correct |
11 |
Incorrect |
20 ms |
3232 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |