Submission #933813

#TimeUsernameProblemLanguageResultExecution timeMemory
933813alexander707070Worst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
2094 ms28240 KiB
#include<bits/stdc++.h> #define MAXN 500007 using namespace std; struct qr{ int t,l,r,id; inline friend bool operator < (qr fr,qr sc){ return fr.t<sc.t; } }; int n,q,t,l,r,tim,ans[MAXN],d[MAXN],pos[MAXN]; qr query[MAXN]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q; for(int i=1;i<=n;i++){ cin>>d[i]; pos[i]=-i; } for(int i=1;i<=q;i++){ cin>>t>>l>>r; query[i]={t,l,r,i}; } sort(query+1,query+q+1); for(int i=1;i<=q;i++){ while(tim<query[i].t){ tim++; pos[0]++; for(int f=1;f<=n;f++){ if(pos[f-1]-pos[f]>=d[f]+1){ pos[f]=pos[f-1]-1; }else break; } } for(int f=0;f<=n;f++){ if(pos[f]>=query[i].l and pos[f]<=query[i].r)ans[query[i].id]++; } } for(int i=1;i<=q;i++){ cout<<ans[i]<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...