#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
ll n,ans,a[300005],k[300005];
int main(){
ordered_set st;
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
k[i] = st.order_of_key(a[i]);
st.insert(a[i]);
}
st.clear();
for(int i=n; i>=1; i--){
k[i] *= st.order_of_key(a[i]);
st.insert(a[i]);
ans += k[i];
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
986 ms |
23912 KB |
Output is correct |
3 |
Correct |
1010 ms |
24740 KB |
Output is correct |
4 |
Correct |
932 ms |
24696 KB |
Output is correct |
5 |
Correct |
943 ms |
24724 KB |
Output is correct |
6 |
Correct |
950 ms |
24716 KB |
Output is correct |
7 |
Correct |
938 ms |
24844 KB |
Output is correct |
8 |
Correct |
991 ms |
23740 KB |
Output is correct |
9 |
Correct |
741 ms |
14840 KB |
Output is correct |
10 |
Correct |
737 ms |
14712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
4984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
4984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
4984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
986 ms |
23912 KB |
Output is correct |
3 |
Correct |
1010 ms |
24740 KB |
Output is correct |
4 |
Correct |
932 ms |
24696 KB |
Output is correct |
5 |
Correct |
943 ms |
24724 KB |
Output is correct |
6 |
Correct |
950 ms |
24716 KB |
Output is correct |
7 |
Correct |
938 ms |
24844 KB |
Output is correct |
8 |
Correct |
991 ms |
23740 KB |
Output is correct |
9 |
Correct |
741 ms |
14840 KB |
Output is correct |
10 |
Correct |
737 ms |
14712 KB |
Output is correct |
11 |
Incorrect |
97 ms |
4984 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |