# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125013 | HassenAissa | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 1219 ms | 25424 KiB |
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>
using namespace std;
vector<int> posi;
vector<int> tab;
long long n;
int main()
{
long long m,x,t,y;
scanf("%lld%lld",&n,&m);
//tab.push_back(1);
posi.resize(n+1);
for(long long i=0; i<n; i++)
{
scanf("%lld",&x);
tab.push_back(x);
}
posi[0]=1;
for(long long i=1; i<=n; i++)
{
if(posi[i-1]>=tab[i-1])
posi[i]=posi[i-1];
else
posi[i]=posi[i-1]*((tab[i-1]+posi[i-1]-1)/posi[i-1]);
}
for(long long i=0; i<m; i++)
{
scanf("%lld%lld%lld",&t,&x,&y);
bool cond=0;
long long l=0,r=posi.size()-1;
long long fir=0;
long long sec=0;
while(l<=r)
{
long long mid=(l+r)/2;
long long p = posi[mid]*(t/posi[mid]) - mid;
if(p>=x && p<=y)
{
r=mid-1;
fir=mid;
cond=true;
}
else if(p<x)
{
r=mid-1;
}
else
{
l=mid+1;
}
}
if(cond==0)
{
cout << 0 << endl;
continue;
}
l=fir;
r=posi.size()-1;
while(l<=r)
{
long long mid=(l+r)/2;
long long p = posi[mid]*(t/posi[mid]) -mid;
if(p>=x && p<=y)
{
l=mid+1;
sec=mid;
}
else if(p<x)
{
r=mid-1;
}
else
{
l=mid+1;
}
}
printf("%lld\n",sec-fir+1);
}
}
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... |