Submission #771203

# Submission time Handle Problem Language Result Execution time Memory
771203 2023-07-02T15:21:30 Z Mohammad_Parsa Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
524 ms 30500 KB
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mk make_pair
typedef long long ll;

const int N=5e5+7;
ll n,q,d[N],s[N],x[N];

ll pos(int i,ll t){
	return -i+(t/s[i])*x[i];
}

int main(){
	ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>d[i];
	}
	s[0]=1,x[0]=1;
	for(int i=1;i<=n;i++){
		ll f=d[i]/x[i-1]+(d[i]%x[i-1]!=0);
		s[i]=f*s[i-1];
		x[i]=f*x[i-1];
	}

	while(q--){
		ll t,s,e;
		cin>>t>>s>>e;
		int L,R=0;
		int l=-1,r=n;
		while(r-l>1){
			int m=(l+r)/2;
			if(pos(m,t)<=e)r=m;
			else l=m;
		}
		L=r;
		l=0,r=n+1;
		while(r-l>1){
			int m=(l+r)/2;
			//cout<<m<<endl;
			if(pos(m,t)>=s)l=m;
			else r=m;
		}
		
		R=l;
		if(pos(L,t)<s)L++;
		
		cout<<R-L+1<<endl;
		//cout<<L<<" "<<R<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 524 ms 30500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 524 ms 30500 KB Output isn't correct
2 Halted 0 ms 0 KB -