Submission #47014

#TimeUsernameProblemLanguageResultExecution timeMemory
47014vanogamWorst Reporter 3 (JOI18_worst_reporter3)C++14
19 / 100
1743 ms98528 KiB
#include<bits/stdc++.h> using namespace std; int a,s,d[500005],f,g,h,j,k,l,i,n,m; int pos(int idx){ return -idx+h/d[idx]*d[idx]; } int main(){ ios_base::sync_with_stdio(0); cin>>n>>m; d[0]=1; for(i=1;i<=n;i++){ cin>>a; d[i]=(a+d[i-1]-1)/d[i-1]*d[i-1]; //cout<<"*"<<d[i]<<endl; } for(i=0;i<m;i++){ cin>>h>>a>>s; int l=-1,r=n+1,p1,p2; while(r-l>1){ int k=(l+r)/2; //cout<<"*"<<k<<" "<<h<<" "<<pos(k)<<endl;cout<<"#"; if(pos(k)<a) {r=k;} else l=k; } p1=l; l=-1;r=n+1; while(r-l>1){ int k=(l+r)/2;//cout<<" *"<<k<<" "<<h<<" "<<pos(k)<<endl; if(pos(k)<=s) {r=k;} else l=k; } p2=l; cout<<p1-p2<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...