Submission #679183

#TimeUsernameProblemLanguageResultExecution timeMemory
679183rainboyWorst Reporter 3 (JOI18_worst_reporter3)C11
19 / 100
265 ms20700 KiB
#include <stdio.h> #define N 500000 #define K 32 /* K = ceil(log2(2 * 10^9)) + 1 */ int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N + 1], ii[K]; int n, q, k, h, i, j; scanf("%d%d", &n, &q); aa[0] = 1; for (i = 1; i <= n; i++) scanf("%d", &aa[i]); for (i = 1; i <= n; i++) aa[i] = (aa[i] + aa[i - 1] - 1) / aa[i - 1] * aa[i - 1]; k = 0; for (i = 0; i <= n; i++) if (i == 0 || aa[i] != aa[i - 1]) ii[k++] = i; while (q--) { int t, l, r, x, ans; scanf("%d%d%d", &t, &l, &r); ans = 0; for (h = 0; h < k; h++) { i = ii[h], j = h + 1 == k ? n : ii[h + 1] - 1, x = t / aa[i] * aa[i]; ans += max(min(x - i, r) - max(x - j, l) + 1, 0); } printf("%d\n", ans); } return 0; }

Compilation message (stderr)

worst_reporter3.c: In function 'main':
worst_reporter3.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
worst_reporter3.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   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...