# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642914 | 2022-09-20T18:59:41 Z | valerikk | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 323 ms | 24608 KB |
#include <cstdio> #define MAXN 500005 #define MAXT 1000000001 #define MAXK 32 int N, Q; int D[MAXN]; int W[MAXN], C[MAXN]; int Z[MAXK], K; int count(int T, int L) { if (T < L) return 0; int low = 0, high = N + 1; while (high - low > 1) { int mid = (low + high) / 2; int X = T - mid; for (int i = 0, t = T; i < K && Z[i] <= mid; ++i) { int r = t % C[Z[i]]; t /= C[Z[i]]; X -= r * W[Z[i]]; } if (X >= L) low = mid; else high = mid; } return low + 1; } int main() { scanf("%d%d", &N, &Q); for (int i = 1; i <= N; ++i) { scanf("%d", &D[i]); } W[1] = 1; C[1] = D[1]; for (int i = 2; i <= N; ++i) { W[i] = C[i - 1] * W[i - 1]; C[i] = (D[i] + W[i] - 1) / W[i]; } for (int i = 1; i <= N; ++i) { if (C[i] != 1) Z[K++] = i; } while (Q--) { int T, L, R; scanf("%d%d%d", &T, &L, &R); printf("%d\n", count(T, L) - count(T, R + 1)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 296 ms | 10764 KB | Output is correct |
2 | Correct | 303 ms | 24588 KB | Output is correct |
3 | Correct | 302 ms | 24600 KB | Output is correct |
4 | Correct | 295 ms | 24588 KB | Output is correct |
5 | Correct | 323 ms | 24552 KB | Output is correct |
6 | Correct | 297 ms | 24608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 232 KB | Output is correct |
6 | Correct | 2 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 296 ms | 10764 KB | Output is correct |
2 | Correct | 303 ms | 24588 KB | Output is correct |
3 | Correct | 302 ms | 24600 KB | Output is correct |
4 | Correct | 295 ms | 24588 KB | Output is correct |
5 | Correct | 323 ms | 24552 KB | Output is correct |
6 | Correct | 297 ms | 24608 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 232 KB | Output is correct |
12 | Correct | 2 ms | 212 KB | Output is correct |
13 | Runtime error | 66 ms | 9212 KB | Execution killed with signal 8 |
14 | Halted | 0 ms | 0 KB | - |