#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_multiset;
ordered_multiset s;
int l[300010], r[300010], arr[300010], n, ans;
signed main() {
cin >> n;
for(int i=1; i<=n; i++) {
cin >> arr[i];
l[i] = s.order_of_key(arr[i]);
s.insert(arr[i]);
}
s.clear();
for(int i=n; i>=1; i--) {
r[i] = s.order_of_key(arr[i]);
s.insert(arr[i]);
}
for(int i=1; i<=n; i++) {
ans += l[i]*r[i];
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |