Submission #329139

#TimeUsernameProblemLanguageResultExecution timeMemory
329139oakMountains (NOI20_mountains)C++14
0 / 100
2092 ms3108 KiB
#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)

Mountains.cpp: In function 'int main()':
Mountains.cpp:4:8: warning: unused variable 'j' [-Wunused-variable]
    4 |  int n,j,i;
      |        ^
Mountains.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    5 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
Mountains.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |   scanf("%d",&arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...