Submission #389093

#TimeUsernameProblemLanguageResultExecution timeMemory
389093denkendoemeerWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
765 ms29316 KiB
#include<bits/stdc++.h> #define ll long long const int inf=1e9; using namespace std; ll d[600006],dp[600005]; int n; int calc(ll x,ll t) { ll st=-1,dr=n+1; while(dr-st>1){ int mij=(st+dr)/2; if (-mij+(t/dp[mij])*dp[mij]>=x) st=mij; else dr=mij; } return dr; } int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); int q,i; scanf("%d%d",&n,&q); for(i=1;i<=n;i++) scanf("%lld",&d[i]); dp[0]=1; for(i=1;i<=n;i++){ ll aux=(d[i]+dp[i-1]-1)/dp[i-1]; dp[i]=aux*dp[i-1]; } for(i=1;i<=q;i++){ ll t,l,r; scanf("%lld%lld%lld",&t,&l,&r); printf("%d\n",calc(l,t)-calc(r+1,t)); } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |         scanf("%lld",&d[i]);
      |         ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |         scanf("%lld%lld%lld",&t,&l,&r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...