# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1228119 | _rain_ | Worst Reporter 3 (JOI18_worst_reporter3) | C++20 | 309 ms | 7356 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=(int)5e5;
LL pre[N+2]={},a[N+2]={};
int n,q;
LL point(LL x,LL y,LL t){
return x*(t/x)-y;
}
int lef_most(int t,int limit){
int low=0,high=n,pos=n+1;
while (low<=high){
int mid=(low+high)/2;
if (point(a[mid],mid,t)<=limit){
pos=mid;
high=mid-1;
}
else low=mid+1;
}
return n-pos;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0) ; cout.tie(0);
#define task "main"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin>>n>>q;
a[0]=1;
for(int i=1;i<=n;++i) {
cin>>a[i];
a[i]=((a[i]-1)/a[i-1]+1)*a[i-1];
}
while(q--){
int t,l,r; cin>>t>>l>>r;
cout<<lef_most(t,r)-lef_most(t,l-1)<<'\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |