Submission #125013

#TimeUsernameProblemLanguageResultExecution timeMemory
125013HassenAissaWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
1219 ms25424 KiB
#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)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
         ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&t,&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...