# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
329139 | oak | Mountains (NOI20_mountains) | C++14 | 2092 ms | 3108 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>
using namespace std;
int main(){
int n,j,i;
scanf("%d",&n);
int arr[n],sum[n];
multiset<int> ms;
for(i=0;i<n;i++){
scanf("%d",&arr[i]);
ms.insert(arr[i]);
sum[i] = distance(ms.begin(),ms.lower_bound(arr[i]));
//printf("%d ",sum[i]);
}
//printf("\n");
long long ans = 0;
ms.clear();
for(i=n-1;i>=0;i--){
ms.insert(arr[i]);
sum[i] *= distance(ms.begin(),ms.lower_bound(arr[i]));
ans += sum[i];
//printf("%d ",sum[i]);
}
//printf("\n");
printf("%lld",ans);
}
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... |