Submission #1228119

#TimeUsernameProblemLanguageResultExecution timeMemory
1228119_rain_Worst Reporter 3 (JOI18_worst_reporter3)C++20
100 / 100
309 ms7356 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)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:31:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |                 freopen(task".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:32:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |                 freopen(task".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...