Submission #44709

#TimeUsernameProblemLanguageResultExecution timeMemory
44709top34051Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
1131 ms7644 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 5e5 + 5; int n,q; ll dist[maxn]; int get(ll T, ll L) { int l = 0, r = n, mid, pos = -1; while(l<=r) { mid = (l+r)/2; if(L <= -mid + (T/dist[mid])*dist[mid]) { pos = mid; l = mid+1; } else r = mid-1; } return pos; } int main() { scanf("%d%d",&n,&q); dist[0] = 1; for(int i=1;i<=n;i++) { scanf("%lld",&dist[i]); dist[i] = (ll)ceil((double)dist[i]/dist[i-1]) * dist[i-1]; } while(q--) { ll T, L, R; int res = 0; scanf("%lld%lld%lld",&T,&L,&R); // printf("\t"); // for(int i=1;i<=n;i++) printf("%lld ",-i+(T/dist[i])*dist[i]); // printf("\n"); printf("%d\n",get(T,L) - get(T,R+1)); } }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:31:25: warning: unused variable 'res' [-Wunused-variable]
         ll T, L, R; int res = 0;
                         ^~~
worst_reporter3.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&dist[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:32:14: 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...