Submission #222619

#TimeUsernameProblemLanguageResultExecution timeMemory
222619astoriaFire (JOI20_ho_t5)C++14
6 / 100
578 ms24964 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ multiset<int> ms; int n,q; cin>>n>>q; int s[n+5]; for(int i=1; i<=n; i++) cin>>s[i]; int t[q],l[q],r[q]; for(int i=0; i<q; i++) cin>>t[i]>>l[i]>>r[i]; int val[n+5]; val[0] = 0; for(int i=1; i<=min(t[0]+1,n); i++){ ms.insert(s[i]); val[i] = *ms.rbegin(); } for(int i=t[0]+2; i<=n; i++){ ms.insert(s[i]); ms.erase(ms.find(s[i-t[0]-1])); val[i] = *ms.rbegin(); } int p[n+5]; p[0]=0; for(int i=1; i<=n; i++) p[i]=p[i-1]+val[i]; for(int i=0; i<q; i++){ cout<<(p[r[i]]-p[l[i]-1])<<'\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...