# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60244 | 2018-07-23T22:25:21 Z | ainta | Sparklers (JOI17_sparklers) | C++17 | 70 ms | 12384 KB |
#include<cstdio> #include<algorithm> #define N_ 101000 using namespace std; int n, st, n1, n2, D[N_]; long long T, INF = 1e9, X[N_]; long long A[N_], B[N_], AA[N_], BB[N_]; struct point { int pv; long long Mn, Mx; }w[N_]; bool Do() { int i, cnt = 0; n1--, n2--; long long Mx = -4e18, Mn = 4e18; for (i = 0; i <= n2; i++) { Mn = min(Mn, B[i]); if (Mx <= B[i]) { Mx = B[i]; w[cnt++] = { i,Mn,Mx }; Mn = B[i]; } } for (i = 0; i < cnt; i++) { if (w[i].Mn + A[0] < 0)break; } D[0] = i - 1; if (D[0] == -1)return false; for (i = 1; i <= n1; i++) { if (w[D[i - 1]].Mx + A[i] < 0)return false; int pv = D[i - 1]; while (pv < cnt - 1 && w[pv + 1].Mn + A[i] >= 0)pv++; D[i] = pv; } return w[D[n1]].pv == n2; } bool Pos(long long KK) { long long L = T*KK; if (L >= 1e9)return true; int i, j; for (i = st; i >= 1; i--) { AA[i] = X[i] + L * 2 * (st - i); } for (i = st; i <= n; i++) { BB[i] = -(X[i] - L * 2 * (i - st)); } int pv1 = st, pv2 = st; for (i = st; i >= 1; i--) if (AA[pv1] < AA[i])pv1 = i; for (i = st; i <= n; i++) if (BB[pv2] < BB[i])pv2 = i; n1 = 0, n2 = 0; for (i = st; i >= pv1; i--) A[n1++] = AA[i]; for (i = st; i <= pv2; i++) B[n2++] = BB[i]; if (!Do())return false; n1 = 0, n2 = 0; for (i = 1; i <= pv1; i++) A[n1++] = AA[i]; for (i = n; i >= pv2; i--) B[n2++] = BB[i]; if (!Do())return false; return true; } int main() { int i; scanf("%d%d%lld", &n, &st, &T); for (i = 1; i <= n; i++) { scanf("%lld", &X[i]); } long long b = 0, e = 1e9, mid, res; while (b <= e) { mid = (b + e) / 2; if (Pos(mid)) { res = mid; e = mid - 1; } else b = mid + 1; } printf("%d\n", res); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 652 KB | Output is correct |
6 | Correct | 3 ms | 652 KB | Output is correct |
7 | Correct | 3 ms | 652 KB | Output is correct |
8 | Correct | 2 ms | 716 KB | Output is correct |
9 | Correct | 2 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 716 KB | Output is correct |
11 | Correct | 2 ms | 716 KB | Output is correct |
12 | Correct | 2 ms | 716 KB | Output is correct |
13 | Correct | 2 ms | 716 KB | Output is correct |
14 | Correct | 2 ms | 744 KB | Output is correct |
15 | Correct | 2 ms | 744 KB | Output is correct |
16 | Correct | 2 ms | 744 KB | Output is correct |
17 | Correct | 2 ms | 744 KB | Output is correct |
18 | Correct | 3 ms | 744 KB | Output is correct |
19 | Correct | 3 ms | 744 KB | Output is correct |
20 | Correct | 3 ms | 744 KB | Output is correct |
21 | Correct | 3 ms | 744 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 652 KB | Output is correct |
6 | Correct | 3 ms | 652 KB | Output is correct |
7 | Correct | 3 ms | 652 KB | Output is correct |
8 | Correct | 2 ms | 716 KB | Output is correct |
9 | Correct | 2 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 716 KB | Output is correct |
11 | Correct | 2 ms | 716 KB | Output is correct |
12 | Correct | 2 ms | 716 KB | Output is correct |
13 | Correct | 2 ms | 716 KB | Output is correct |
14 | Correct | 2 ms | 744 KB | Output is correct |
15 | Correct | 2 ms | 744 KB | Output is correct |
16 | Correct | 2 ms | 744 KB | Output is correct |
17 | Correct | 2 ms | 744 KB | Output is correct |
18 | Correct | 3 ms | 744 KB | Output is correct |
19 | Correct | 3 ms | 744 KB | Output is correct |
20 | Correct | 3 ms | 744 KB | Output is correct |
21 | Correct | 3 ms | 744 KB | Output is correct |
22 | Correct | 3 ms | 744 KB | Output is correct |
23 | Correct | 3 ms | 744 KB | Output is correct |
24 | Correct | 2 ms | 744 KB | Output is correct |
25 | Correct | 3 ms | 912 KB | Output is correct |
26 | Correct | 3 ms | 912 KB | Output is correct |
27 | Correct | 3 ms | 912 KB | Output is correct |
28 | Correct | 4 ms | 912 KB | Output is correct |
29 | Correct | 2 ms | 912 KB | Output is correct |
30 | Correct | 3 ms | 912 KB | Output is correct |
31 | Correct | 3 ms | 912 KB | Output is correct |
32 | Correct | 4 ms | 912 KB | Output is correct |
33 | Correct | 3 ms | 912 KB | Output is correct |
34 | Correct | 3 ms | 912 KB | Output is correct |
35 | Correct | 3 ms | 912 KB | Output is correct |
36 | Correct | 4 ms | 912 KB | Output is correct |
37 | Correct | 3 ms | 912 KB | Output is correct |
38 | Correct | 4 ms | 912 KB | Output is correct |
39 | Correct | 3 ms | 912 KB | Output is correct |
40 | Correct | 3 ms | 912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 520 KB | Output is correct |
5 | Correct | 3 ms | 652 KB | Output is correct |
6 | Correct | 3 ms | 652 KB | Output is correct |
7 | Correct | 3 ms | 652 KB | Output is correct |
8 | Correct | 2 ms | 716 KB | Output is correct |
9 | Correct | 2 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 716 KB | Output is correct |
11 | Correct | 2 ms | 716 KB | Output is correct |
12 | Correct | 2 ms | 716 KB | Output is correct |
13 | Correct | 2 ms | 716 KB | Output is correct |
14 | Correct | 2 ms | 744 KB | Output is correct |
15 | Correct | 2 ms | 744 KB | Output is correct |
16 | Correct | 2 ms | 744 KB | Output is correct |
17 | Correct | 2 ms | 744 KB | Output is correct |
18 | Correct | 3 ms | 744 KB | Output is correct |
19 | Correct | 3 ms | 744 KB | Output is correct |
20 | Correct | 3 ms | 744 KB | Output is correct |
21 | Correct | 3 ms | 744 KB | Output is correct |
22 | Correct | 3 ms | 744 KB | Output is correct |
23 | Correct | 3 ms | 744 KB | Output is correct |
24 | Correct | 2 ms | 744 KB | Output is correct |
25 | Correct | 3 ms | 912 KB | Output is correct |
26 | Correct | 3 ms | 912 KB | Output is correct |
27 | Correct | 3 ms | 912 KB | Output is correct |
28 | Correct | 4 ms | 912 KB | Output is correct |
29 | Correct | 2 ms | 912 KB | Output is correct |
30 | Correct | 3 ms | 912 KB | Output is correct |
31 | Correct | 3 ms | 912 KB | Output is correct |
32 | Correct | 4 ms | 912 KB | Output is correct |
33 | Correct | 3 ms | 912 KB | Output is correct |
34 | Correct | 3 ms | 912 KB | Output is correct |
35 | Correct | 3 ms | 912 KB | Output is correct |
36 | Correct | 4 ms | 912 KB | Output is correct |
37 | Correct | 3 ms | 912 KB | Output is correct |
38 | Correct | 4 ms | 912 KB | Output is correct |
39 | Correct | 3 ms | 912 KB | Output is correct |
40 | Correct | 3 ms | 912 KB | Output is correct |
41 | Correct | 28 ms | 3580 KB | Output is correct |
42 | Correct | 4 ms | 3580 KB | Output is correct |
43 | Correct | 10 ms | 3580 KB | Output is correct |
44 | Correct | 49 ms | 7152 KB | Output is correct |
45 | Correct | 51 ms | 7216 KB | Output is correct |
46 | Correct | 52 ms | 8948 KB | Output is correct |
47 | Correct | 56 ms | 9752 KB | Output is correct |
48 | Correct | 68 ms | 10360 KB | Output is correct |
49 | Correct | 67 ms | 12108 KB | Output is correct |
50 | Correct | 63 ms | 12108 KB | Output is correct |
51 | Correct | 61 ms | 12232 KB | Output is correct |
52 | Correct | 47 ms | 12232 KB | Output is correct |
53 | Correct | 54 ms | 12384 KB | Output is correct |
54 | Correct | 49 ms | 12384 KB | Output is correct |
55 | Correct | 70 ms | 12384 KB | Output is correct |
56 | Correct | 44 ms | 12384 KB | Output is correct |
57 | Correct | 46 ms | 12384 KB | Output is correct |
58 | Correct | 58 ms | 12384 KB | Output is correct |
59 | Correct | 38 ms | 12384 KB | Output is correct |
60 | Correct | 48 ms | 12384 KB | Output is correct |
61 | Correct | 47 ms | 12384 KB | Output is correct |
62 | Correct | 46 ms | 12384 KB | Output is correct |
63 | Correct | 43 ms | 12384 KB | Output is correct |
64 | Correct | 42 ms | 12384 KB | Output is correct |
65 | Correct | 44 ms | 12384 KB | Output is correct |
66 | Correct | 42 ms | 12384 KB | Output is correct |
67 | Correct | 48 ms | 12384 KB | Output is correct |
68 | Correct | 62 ms | 12384 KB | Output is correct |
69 | Correct | 57 ms | 12384 KB | Output is correct |