Submission #58909

#TimeUsernameProblemLanguageResultExecution timeMemory
58909TadijaSebezWorst Reporter 3 (JOI18_worst_reporter3)C++11
19 / 100
1232 ms263168 KiB
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; #define ll long long const int N=500050; ll jump[N]; int main() { int n,q,i; ll x,l,r,t; scanf("%i %i",&n,&q); jump[0]=1; for(i=1;i<=n;i++) { scanf("%lld",&x); jump[i]=((x+jump[i-1]-1)/jump[i-1])*jump[i-1]; } while(q--) { scanf("%lld %lld %lld",&t,&l,&r); int top=n,bot=0,mid,L=0; while(top>=bot) { mid=top+bot>>1; if(t/jump[mid]*jump[mid]-mid>=l) L=mid+1,bot=mid+1; else top=mid-1; } top=n,bot=0;int R=0; while(top>=bot) { mid=top+bot>>1; if(t/jump[mid]*jump[mid]-mid>r) R=mid+1,bot=mid+1; else top=mid-1; } printf("%i\n",L-R); } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:25:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
worst_reporter3.cpp:32:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
worst_reporter3.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&q);
  ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
   ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   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...