Submission #258295

#TimeUsernameProblemLanguageResultExecution timeMemory
258295FidiskWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
632 ms29536 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e18 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) #define _cos(xxxx) cos(xxxx*acos(-1)/180) #define _sin(xxxx) sin(xxxx*acos(-1)/180) #define _tan(xxxx) tan(xxxx*acos(-1)/180) #define PE cout<<fixed typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; const ld pi=acos(-1); ll n,q,i,a[500009],b[500009],pos,t,lt,rt,l,r,mid,rres,lres; int main(){ IO; cin>>n>>q; for (i=1;i<=n;i++) { cin>>a[i]; } b[0]=1; for (i=1;i<=n;i++) { b[i]=((a[i]+b[i-1]-1)/b[i-1])*b[i-1]; } for (i=1;i<=q;i++) { cin>>t>>lt>>rt; l=-1; r=n+1; while ((l+1)!=r) { mid=(r+l)/2; pos=(t/b[mid])*b[mid]-mid; //cout<<l<<' '<<r<<' '<<mid<<' '<<pos<<'\n'; if (pos>=lt) { l=mid; } else { r=mid; } } //cout<<l<<' '<<r<<'\n'; rres=r; l=-1; r=n+1; while ((l+1)!=r) { mid=(r+l)/2; pos=(t/b[mid])*b[mid]-mid; //cout<<l<<' '<<r<<' '<<mid<<' '<<pos<<'\n'; if (pos<=rt) { r=mid; } else { l=mid; } } //cout<<l<<' '<<r<<'\n'; lres=r; cout<<rres-lres<<'\n'; //cout<<"------------\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...