# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131480 | 2019-07-17T07:56:39 Z | 송준혁(#3182) | Sparklers (JOI17_sparklers) | C++14 | 313 ms | 32408 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, int> pii; int N, K; LL A[2020], P, ans; LL D[2020][2020]; bool chk(LL k){ memset(D, -1, sizeof D); D[K][K] = P*2*k; for (int i=1; i<N; i++){ for (int j=1; j+i-1<=N; j++){ if (D[j][j+i-1] < 0) continue; if (j > 1 && A[j] - A[j-1] <= D[j][j+i-1]) D[j-1][j+i-1] = D[j][j+i-1] - (A[j] - A[j-1]) + P*2*k; if (j < N && A[j+i] - A[j+i-1] <= D[j][j+i-1]) D[j][j+i] = D[j][j+i-1] - (A[j+i] - A[j+i-1]) + P*2*k; } } if (D[1][N] >= 0) return true; return false; } int main(){ scanf("%d %d %lld", &N, &K, &P); for (int i=1; i<=N; i++) scanf("%lld", &A[i]); if (A[1] == A[N]){ puts("0"); return 0; } LL L = 1, R = 1000000000; while (L <= R){ LL mid = (L+R)/2; if (chk(mid)) R = mid-1, ans = mid; else L = mid+1; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 164 ms | 32304 KB | Output is correct |
2 | Correct | 260 ms | 32376 KB | Output is correct |
3 | Correct | 189 ms | 32308 KB | Output is correct |
4 | Correct | 223 ms | 32300 KB | Output is correct |
5 | Correct | 186 ms | 32308 KB | Output is correct |
6 | Correct | 197 ms | 32300 KB | Output is correct |
7 | Correct | 184 ms | 32308 KB | Output is correct |
8 | Correct | 186 ms | 32376 KB | Output is correct |
9 | Correct | 185 ms | 32248 KB | Output is correct |
10 | Correct | 188 ms | 32248 KB | Output is correct |
11 | Correct | 241 ms | 32308 KB | Output is correct |
12 | Correct | 187 ms | 32348 KB | Output is correct |
13 | Correct | 208 ms | 32376 KB | Output is correct |
14 | Correct | 183 ms | 32188 KB | Output is correct |
15 | Correct | 184 ms | 32376 KB | Output is correct |
16 | Correct | 183 ms | 32376 KB | Output is correct |
17 | Correct | 281 ms | 32248 KB | Output is correct |
18 | Correct | 267 ms | 32248 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 197 ms | 32248 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 164 ms | 32304 KB | Output is correct |
2 | Correct | 260 ms | 32376 KB | Output is correct |
3 | Correct | 189 ms | 32308 KB | Output is correct |
4 | Correct | 223 ms | 32300 KB | Output is correct |
5 | Correct | 186 ms | 32308 KB | Output is correct |
6 | Correct | 197 ms | 32300 KB | Output is correct |
7 | Correct | 184 ms | 32308 KB | Output is correct |
8 | Correct | 186 ms | 32376 KB | Output is correct |
9 | Correct | 185 ms | 32248 KB | Output is correct |
10 | Correct | 188 ms | 32248 KB | Output is correct |
11 | Correct | 241 ms | 32308 KB | Output is correct |
12 | Correct | 187 ms | 32348 KB | Output is correct |
13 | Correct | 208 ms | 32376 KB | Output is correct |
14 | Correct | 183 ms | 32188 KB | Output is correct |
15 | Correct | 184 ms | 32376 KB | Output is correct |
16 | Correct | 183 ms | 32376 KB | Output is correct |
17 | Correct | 281 ms | 32248 KB | Output is correct |
18 | Correct | 267 ms | 32248 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 197 ms | 32248 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
22 | Correct | 291 ms | 32316 KB | Output is correct |
23 | Correct | 217 ms | 32248 KB | Output is correct |
24 | Correct | 229 ms | 32312 KB | Output is correct |
25 | Correct | 257 ms | 32376 KB | Output is correct |
26 | Correct | 280 ms | 32348 KB | Output is correct |
27 | Correct | 299 ms | 32408 KB | Output is correct |
28 | Correct | 313 ms | 32376 KB | Output is correct |
29 | Correct | 302 ms | 32320 KB | Output is correct |
30 | Correct | 286 ms | 32388 KB | Output is correct |
31 | Correct | 290 ms | 32376 KB | Output is correct |
32 | Correct | 301 ms | 32380 KB | Output is correct |
33 | Correct | 308 ms | 32356 KB | Output is correct |
34 | Correct | 261 ms | 32248 KB | Output is correct |
35 | Correct | 292 ms | 32376 KB | Output is correct |
36 | Correct | 266 ms | 32248 KB | Output is correct |
37 | Correct | 253 ms | 32248 KB | Output is correct |
38 | Correct | 298 ms | 32396 KB | Output is correct |
39 | Correct | 290 ms | 32356 KB | Output is correct |
40 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 164 ms | 32304 KB | Output is correct |
2 | Correct | 260 ms | 32376 KB | Output is correct |
3 | Correct | 189 ms | 32308 KB | Output is correct |
4 | Correct | 223 ms | 32300 KB | Output is correct |
5 | Correct | 186 ms | 32308 KB | Output is correct |
6 | Correct | 197 ms | 32300 KB | Output is correct |
7 | Correct | 184 ms | 32308 KB | Output is correct |
8 | Correct | 186 ms | 32376 KB | Output is correct |
9 | Correct | 185 ms | 32248 KB | Output is correct |
10 | Correct | 188 ms | 32248 KB | Output is correct |
11 | Correct | 241 ms | 32308 KB | Output is correct |
12 | Correct | 187 ms | 32348 KB | Output is correct |
13 | Correct | 208 ms | 32376 KB | Output is correct |
14 | Correct | 183 ms | 32188 KB | Output is correct |
15 | Correct | 184 ms | 32376 KB | Output is correct |
16 | Correct | 183 ms | 32376 KB | Output is correct |
17 | Correct | 281 ms | 32248 KB | Output is correct |
18 | Correct | 267 ms | 32248 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 197 ms | 32248 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
22 | Correct | 291 ms | 32316 KB | Output is correct |
23 | Correct | 217 ms | 32248 KB | Output is correct |
24 | Correct | 229 ms | 32312 KB | Output is correct |
25 | Correct | 257 ms | 32376 KB | Output is correct |
26 | Correct | 280 ms | 32348 KB | Output is correct |
27 | Correct | 299 ms | 32408 KB | Output is correct |
28 | Correct | 313 ms | 32376 KB | Output is correct |
29 | Correct | 302 ms | 32320 KB | Output is correct |
30 | Correct | 286 ms | 32388 KB | Output is correct |
31 | Correct | 290 ms | 32376 KB | Output is correct |
32 | Correct | 301 ms | 32380 KB | Output is correct |
33 | Correct | 308 ms | 32356 KB | Output is correct |
34 | Correct | 261 ms | 32248 KB | Output is correct |
35 | Correct | 292 ms | 32376 KB | Output is correct |
36 | Correct | 266 ms | 32248 KB | Output is correct |
37 | Correct | 253 ms | 32248 KB | Output is correct |
38 | Correct | 298 ms | 32396 KB | Output is correct |
39 | Correct | 290 ms | 32356 KB | Output is correct |
40 | Correct | 2 ms | 376 KB | Output is correct |
41 | Incorrect | 3 ms | 504 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |