Submission #572419

#TimeUsernameProblemLanguageResultExecution timeMemory
572419PiejanVDCPilot (NOI19_pilot)C++17
55 / 100
1097 ms1696 KiB
#include <bits/stdc++.h> using namespace std; signed main() { int n,q; cin>>n>>q; vector<int>v(n); for(auto &z : v) { cin>>z; } v.push_back(INT_MAX); while(q--) { int h; cin>>h; if(h == (int)1e6) { long long x = n; cout << (x * (x+1))/2 << '\n'; continue; } long long cnt = 0; long long ans = 0; for(int i = 0 ; i <= n ; i++) { if(v[i] <= h) { cnt++; } else { ans += (cnt * (cnt+1))/2; cnt = 0; } } cout << ans << '\n'; } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...