Submission #535795

#TimeUsernameProblemLanguageResultExecution timeMemory
53579579brueWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
754 ms33300 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; ll arr[500002]; ll ta[500002], len[500002]; int calc(ll t, ll x){ int l = 0, r = n, ans = -1; while(l <= r){ int m = (l+r)>>1; if((t / ta[m]) * len[m] - m >= x){ ans = m; l = m+1; } else r = m-1; } return ans; } int main(){ scanf("%d %d", &n, &q); for(int i=1; i<=n; i++) scanf("%lld", &arr[i]); ta[0] = 1, len[0] = 1; for(int i=1; i<=n; i++){ ta[i] = ta[i-1] * ((arr[i] + len[i-1] - 1) / len[i-1]); len[i] = ta[i] / ta[i-1] * len[i-1]; } while(q--){ ll t, l, r; scanf("%lld %lld %lld", &t, &l, &r); printf("%d\n", calc(t, l) - calc(t, r+1)); } }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:26:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         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...