Submission #286810

#TimeUsernameProblemLanguageResultExecution timeMemory
286810YJUWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
26 ms4480 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll MOD=1e9+7; const ll N=2e5+5; const ld pi=3.14159265359; const ll INF=(1LL<<62); #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(a) (ll)a.size() ll T,L,R,n,q,l[N],d[N],t[N]; ll cal(ll tid,ll range){ ll ql=-1,qr=n+1; while(qr-ql>1){ ll mid=(ql+qr)/2; if(tid/t[mid]*l[mid]-mid>range){ ql=mid; }else{ qr=mid; } } return (n+1-qr); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>q; l[0]=t[0]=1; REP1(i,n)cin>>d[i]; REP1(i,n){ l[i]=((d[i]+l[i-1]-1)/l[i-1])*l[i-1]; t[i]=t[i-1]*((d[i]+l[i-1]-1)/l[i-1]); if(t[i]>1e9){n=i;break;} } while(q--){ cin>>T>>L>>R; //cout<<cal(T,R)<<" "<<cal(T,L-1)<<"\n"; cout<<cal(T,R)-cal(T,L-1)<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...