This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t[600000];
int suma[600000];
int n;
int licz(int kiedy,int x)
{
int pocz=0,kon=n,sre;
while(pocz<=kon)
{
sre=(pocz+kon)/2;
if(kiedy/suma[sre]*suma[sre]-sre>=x)
pocz=sre+1;
else kon=sre-1;
}
return kon+1;
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int zap,tt,l,r;
cin>>n>>zap;
for(int i=1;i<=n;i++)
cin>>t[i];
suma[0]=1;
for(int i=1;i<=n;i++)
{
suma[i]=max(t[i],suma[i-1]);
suma[i]=suma[i-1]*((suma[i-1]+suma[i]-1)/suma[i-1]);
}
while(zap--)
{
cin>>tt>>l>>r;
cout<<licz(tt,l)-licz(tt,r+1)<<"\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |