# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092792 | Sunbae | Mountains (NOI20_mountains) | C++17 | 427 ms | 29440 KiB |
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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define os tree<pair<ll,int>, null_type, less<pair<ll,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 3e5 + 5;
ll A[N], a[N], tot;
signed main(){
int n; scanf("%d", &n);
os s;
for(int i = 0; i<n; ++i){
scanf("%lld", a+i);
A[i] = s.order_of_key(make_pair(a[i], -1));
s.insert(make_pair(a[i], i));
}
s.clear();
for(int i = n-1; i>=0; --i){
tot += A[i] *= s.order_of_key(make_pair(a[i], -1));
s.insert(make_pair(a[i], i));
}
printf("%lld", tot);
}
Compilation message (stderr)
# | 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... |