# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
642915 | 2022-09-20T19:00:11 Z | valerikk | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 305 ms | 9280 KB |
#include <cstdio> #define MAXN 500005 #define MAXT 1000000001 #define MAXK 65 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 292 ms | 9056 KB | Output is correct |
2 | Correct | 305 ms | 9056 KB | Output is correct |
3 | Correct | 296 ms | 9084 KB | Output is correct |
4 | Correct | 297 ms | 9280 KB | Output is correct |
5 | Correct | 302 ms | 9152 KB | Output is correct |
6 | Correct | 283 ms | 9152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 292 ms | 9056 KB | Output is correct |
2 | Correct | 305 ms | 9056 KB | Output is correct |
3 | Correct | 296 ms | 9084 KB | Output is correct |
4 | Correct | 297 ms | 9280 KB | Output is correct |
5 | Correct | 302 ms | 9152 KB | Output is correct |
6 | Correct | 283 ms | 9152 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 | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Runtime error | 60 ms | 4328 KB | Execution killed with signal 8 |
14 | Halted | 0 ms | 0 KB | - |