Submission #205525

#TimeUsernameProblemLanguageResultExecution timeMemory
205525PeppaPigWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
927 ms26616 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 5e5+5; int n, q; long s[N], t[N]; int cnt(long T, long R) { int l = 0, r = n; while(l < r) { int mid = (l + r) >> 1; if(s[mid] * (T / t[mid]) - mid <= R) r = mid; else l = mid + 1; } return n + 1 - r; } int main() { scanf("%d %d", &n, &q); s[0] = t[0] = 1; for(int i = 1, d; i <= n; i++) { scanf("%d", &d); long k = d / s[i-1] + (d % s[i-1] != 0); s[i] = s[i-1] * k, t[i] = t[i-1] * k; } for(int i = 1, t, l, r; i <= q; i++) { scanf("%d %d %d", &t, &l, &r); printf("%d\n", cnt(t, r) - cnt(t, l-1)); } return 0; }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:23: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:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &d);
         ~~~~~^~~~~~~~~~
worst_reporter3.cpp:31:14: 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...