Submission #329141

#TimeUsernameProblemLanguageResultExecution timeMemory
329141M_WMountains (NOI20_mountains)C++14
0 / 100
2095 ms7204 KiB
#include <bits/stdc++.h> using namespace std; int h[300300]; vector<int> v; int main(){ int N; vector<long long> cnt; scanf("%d", &N); for(int i = 0; i < N; i++){ scanf("%d", &h[i]); if(i == 0){ v.push_back(h[i]); cnt.push_back(0); continue; } auto it = upper_bound(v.begin(), v.end(), h[i]); v.insert(it, h[i]); cnt.push_back(lower_bound(v.begin(), v.end(), h[i]) - v.begin()); } v.clear(); long long sum = 0; for(int i = N - 1; i >= 0; i--){ if(i == 0){ v.push_back(h[i]); cnt.push_back(0); continue; } auto it = upper_bound(v.begin(), v.end(), h[i]); v.insert(it, h[i]); sum += cnt[i] * 1ll * (lower_bound(v.begin(), v.end(), h[i]) - v.begin()) * 1ll; } printf("%lld", sum); }

Compilation message (stderr)

Mountains.cpp: In function 'int main()':
Mountains.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
Mountains.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%d", &h[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...