# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60002 | 2018-07-23T12:01:14 Z | ainta(#1720) | Sparklers (JOI17_sparklers) | C++11 | 4 ms | 724 KB |
#include<cstdio> #include<algorithm> #define N_ 1010 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 | 1 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 440 KB | Output is correct |
5 | Correct | 2 ms | 440 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 3 ms | 476 KB | Output is correct |
8 | Correct | 3 ms | 476 KB | Output is correct |
9 | Correct | 2 ms | 476 KB | Output is correct |
10 | Correct | 3 ms | 476 KB | Output is correct |
11 | Correct | 3 ms | 476 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 592 KB | Output is correct |
15 | Correct | 3 ms | 592 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 620 KB | Output is correct |
18 | Correct | 2 ms | 620 KB | Output is correct |
19 | Correct | 3 ms | 620 KB | Output is correct |
20 | Correct | 2 ms | 620 KB | Output is correct |
21 | Correct | 4 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 440 KB | Output is correct |
5 | Correct | 2 ms | 440 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 3 ms | 476 KB | Output is correct |
8 | Correct | 3 ms | 476 KB | Output is correct |
9 | Correct | 2 ms | 476 KB | Output is correct |
10 | Correct | 3 ms | 476 KB | Output is correct |
11 | Correct | 3 ms | 476 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 592 KB | Output is correct |
15 | Correct | 3 ms | 592 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 620 KB | Output is correct |
18 | Correct | 2 ms | 620 KB | Output is correct |
19 | Correct | 3 ms | 620 KB | Output is correct |
20 | Correct | 2 ms | 620 KB | Output is correct |
21 | Correct | 4 ms | 620 KB | Output is correct |
22 | Correct | 2 ms | 624 KB | Output is correct |
23 | Correct | 2 ms | 624 KB | Output is correct |
24 | Correct | 4 ms | 624 KB | Output is correct |
25 | Correct | 3 ms | 624 KB | Output is correct |
26 | Correct | 3 ms | 624 KB | Output is correct |
27 | Correct | 3 ms | 624 KB | Output is correct |
28 | Correct | 3 ms | 624 KB | Output is correct |
29 | Correct | 4 ms | 624 KB | Output is correct |
30 | Correct | 3 ms | 624 KB | Output is correct |
31 | Correct | 3 ms | 624 KB | Output is correct |
32 | Correct | 3 ms | 624 KB | Output is correct |
33 | Correct | 4 ms | 624 KB | Output is correct |
34 | Correct | 3 ms | 624 KB | Output is correct |
35 | Correct | 3 ms | 624 KB | Output is correct |
36 | Correct | 3 ms | 724 KB | Output is correct |
37 | Correct | 3 ms | 724 KB | Output is correct |
38 | Correct | 3 ms | 724 KB | Output is correct |
39 | Correct | 4 ms | 724 KB | Output is correct |
40 | Correct | 3 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Correct | 2 ms | 440 KB | Output is correct |
5 | Correct | 2 ms | 440 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 3 ms | 476 KB | Output is correct |
8 | Correct | 3 ms | 476 KB | Output is correct |
9 | Correct | 2 ms | 476 KB | Output is correct |
10 | Correct | 3 ms | 476 KB | Output is correct |
11 | Correct | 3 ms | 476 KB | Output is correct |
12 | Correct | 3 ms | 544 KB | Output is correct |
13 | Correct | 2 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 592 KB | Output is correct |
15 | Correct | 3 ms | 592 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 620 KB | Output is correct |
18 | Correct | 2 ms | 620 KB | Output is correct |
19 | Correct | 3 ms | 620 KB | Output is correct |
20 | Correct | 2 ms | 620 KB | Output is correct |
21 | Correct | 4 ms | 620 KB | Output is correct |
22 | Correct | 2 ms | 624 KB | Output is correct |
23 | Correct | 2 ms | 624 KB | Output is correct |
24 | Correct | 4 ms | 624 KB | Output is correct |
25 | Correct | 3 ms | 624 KB | Output is correct |
26 | Correct | 3 ms | 624 KB | Output is correct |
27 | Correct | 3 ms | 624 KB | Output is correct |
28 | Correct | 3 ms | 624 KB | Output is correct |
29 | Correct | 4 ms | 624 KB | Output is correct |
30 | Correct | 3 ms | 624 KB | Output is correct |
31 | Correct | 3 ms | 624 KB | Output is correct |
32 | Correct | 3 ms | 624 KB | Output is correct |
33 | Correct | 4 ms | 624 KB | Output is correct |
34 | Correct | 3 ms | 624 KB | Output is correct |
35 | Correct | 3 ms | 624 KB | Output is correct |
36 | Correct | 3 ms | 724 KB | Output is correct |
37 | Correct | 3 ms | 724 KB | Output is correct |
38 | Correct | 3 ms | 724 KB | Output is correct |
39 | Correct | 4 ms | 724 KB | Output is correct |
40 | Correct | 3 ms | 724 KB | Output is correct |
41 | Runtime error | 4 ms | 724 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
42 | Halted | 0 ms | 0 KB | - |