# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44994 | 2018-04-10T10:16:03 Z | SpaimaCarpatilor | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 1054 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; int N, M, D[500009], t[500009]; const int INF = 1e9 + 5; int getPos (int T, int i) { int times = T / t[i]; if (1LL * times * D[i] - i > INF) return INF; return -i + times * D[i]; } int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d", &N, &M), D[0] = 1, t[0] = 1; for (int i=1; i<=N; i++) { scanf ("%d", &D[i]); int k = D[i] / D[i - 1]; if (D[i] % D[i - 1] != 0) k ++; D[i] = k * D[i - 1]; if (k <= INF / t[i - 1]) t[i] = k * t[i - 1]; else t[i] = INF; } while (M --) { int T, L, R, p = 0, u = N, l = -1, r = -1; scanf ("%d %d %d", &T, &L, &R); while (p <= u) { int mij = (p + u) >> 1; if (getPos (T, N - mij) <= R) r = mij, p = mij + 1; else u = mij - 1; } if (r == -1) { printf ("0\n"); continue; } p = 0, u = r; while (p <= u) { int mij = (p + u) >> 1; if (getPos (T, N - mij) >= L) l = mij, u = mij - 1; else p = mij + 1; } if (l == -1 || l > r) printf ("0\n"); else printf ("%d\n", r - l + 1); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 847 ms | 22744 KB | Output is correct |
2 | Correct | 924 ms | 38296 KB | Output is correct |
3 | Correct | 789 ms | 53800 KB | Output is correct |
4 | Correct | 861 ms | 69220 KB | Output is correct |
5 | Correct | 1054 ms | 84940 KB | Output is correct |
6 | Correct | 763 ms | 100240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 100240 KB | Output is correct |
2 | Correct | 3 ms | 100240 KB | Output is correct |
3 | Correct | 3 ms | 100240 KB | Output is correct |
4 | Correct | 3 ms | 100240 KB | Output is correct |
5 | Correct | 3 ms | 100240 KB | Output is correct |
6 | Correct | 3 ms | 100240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 847 ms | 22744 KB | Output is correct |
2 | Correct | 924 ms | 38296 KB | Output is correct |
3 | Correct | 789 ms | 53800 KB | Output is correct |
4 | Correct | 861 ms | 69220 KB | Output is correct |
5 | Correct | 1054 ms | 84940 KB | Output is correct |
6 | Correct | 763 ms | 100240 KB | Output is correct |
7 | Correct | 3 ms | 100240 KB | Output is correct |
8 | Correct | 3 ms | 100240 KB | Output is correct |
9 | Correct | 3 ms | 100240 KB | Output is correct |
10 | Correct | 3 ms | 100240 KB | Output is correct |
11 | Correct | 3 ms | 100240 KB | Output is correct |
12 | Correct | 3 ms | 100240 KB | Output is correct |
13 | Correct | 500 ms | 114368 KB | Output is correct |
14 | Correct | 507 ms | 131048 KB | Output is correct |
15 | Correct | 500 ms | 146304 KB | Output is correct |
16 | Correct | 537 ms | 161996 KB | Output is correct |
17 | Correct | 693 ms | 182004 KB | Output is correct |
18 | Correct | 764 ms | 200764 KB | Output is correct |
19 | Correct | 692 ms | 219500 KB | Output is correct |
20 | Correct | 695 ms | 238128 KB | Output is correct |
21 | Correct | 689 ms | 256736 KB | Output is correct |
22 | Correct | 712 ms | 262144 KB | Output is correct |
23 | Correct | 718 ms | 262144 KB | Output is correct |
24 | Correct | 721 ms | 262144 KB | Output is correct |
25 | Correct | 846 ms | 262144 KB | Output is correct |
26 | Correct | 841 ms | 262144 KB | Output is correct |
27 | Correct | 784 ms | 262144 KB | Output is correct |
28 | Correct | 818 ms | 262144 KB | Output is correct |
29 | Correct | 748 ms | 262144 KB | Output is correct |
30 | Correct | 771 ms | 262144 KB | Output is correct |
31 | Correct | 809 ms | 262144 KB | Output is correct |
32 | Correct | 679 ms | 262144 KB | Output is correct |
33 | Correct | 2 ms | 262144 KB | Output is correct |