Submission #120124

#TimeUsernameProblemLanguageResultExecution timeMemory
120124Mamnoon_SiamWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
664 ms25416 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; int n, m; int d[maxn], f[maxn]; int where(int id, int T) { return int(T / f[id]) * f[id] - id; } int count(int lim, int T) { int lo = 1, hi = n, mid, opt = n + 1; while(lo <= hi) { mid = lo + hi >> 1; if(where(mid, T) <= lim) opt = mid, hi = mid - 1; else lo = mid + 1; } return (n + 1) - opt; } int main(int argc, char const *argv[]) { // freopen("in", "r", stdin); scanf("%d %d", &n, &m); d[0] = f[0] = 1; for(int i = 1; i <= n; i++) { scanf("%d", d + i); f[i] = f[i - 1] * ((d[i] - 1) / f[i - 1] + 1); } while(m--) { int l, r, T; scanf("%d %d %d", &T, &l, &r); printf("%d\n", count(r, T) - count(l - 1, T) + (l <= T and T <= r)); } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int count(int, int)':
worst_reporter3.cpp:14:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   mid = lo + hi >> 1;
         ~~~^~~~
worst_reporter3.cpp: In function 'int main(int, const char**)':
worst_reporter3.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", d + i);
   ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &T, &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...