| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 679183 | rainboy | Worst Reporter 3 (JOI18_worst_reporter3) | C11 | 265 ms | 20700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
