This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
ll a[300005],L[300005],R[300005];
main() {
oset s;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i =1 ; i <= n; i++) {
L[i] = s.order_of_key({a[i],0});
s.insert({a[i],i});
}
s.clear();
ll ans = 0;
for (int i = n; i > 0; i--) {
R[i] = s.order_of_key({a[i],0});
s.insert({a[i],i});
ans += (ll)L[i]*R[i];
}
cout << ans;
}
Compilation message (stderr)
Mountains.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main() {
| ^
# | 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... |