# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124655 | Mtaylor | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 1251 ms | 25180 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;
typedef long long ll;
typedef vector<ll> vl ;
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
const int MOD = 1000000007;
const int N = 1000005;
const double PI =4*atan(1);
const double eps = 1e-7;
ll n,q;
ll d[N];
ll l, r, t;
ll tab[N];
int main(){
//ios::sync_with_stdio(0);
//freopen("easy.txt","r",stdin);
cin >> n>> q;
ll res;
for(int i=0;i<n;i++)
scanf("%lld",&d[i]);
tab[0]=1;
for(int i=1;i<=n;i++){
if(tab[i-1]>=d[i]){
tab[i]=tab[i-1];
}else{
//cout << d[i]<< endl;
tab[i] = tab[i-1] * ((d[i-1]+tab[i-1]-1)/tab[i-1]);
}
}
while(q--){
ll x, y, t;
scanf("%lld %lld %lld",&t,&x,&y);
ll l=0, r=n;
bool cond=0;
ll sghir=0;
ll kbir=0;
while(l<=r){
ll mid=(l+r)/2;
ll p = tab[mid]*(t/tab[mid]) -mid;
if(p>=x && p<=y){
r=mid-1;
sghir=mid;
cond=true;
}else if(p<x){
r=mid-1;
}else{
l=mid+1;
}
}
if(cond==0){
cout << 0 << endl;
continue;
}
l=sghir; r=n;
while(l<=r){
ll mid=(l+r)/2;
ll p = tab[mid]*(t/tab[mid]) -mid;
if(p>=x && p<=y){
l=mid+1;
kbir=mid;
}else if(p<x){
r=mid-1;
}else{
l=mid+1;
}
}
printf("%lld\n",kbir-sghir+1);
}
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... |