# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27802 | 2017-07-14T06:37:13 Z | 서규호(#1160) | Sparklers (JOI17_sparklers) | C++14 | 386 ms | 36136 KB |
#include <bits/stdc++.h> #define lld long long #define pii pair<int,int> #define pll pair<lld,lld> #define pb push_back #define next nextt #define left leftt #define right rightt #define Inf 1000000000 #define Linf 1000000000000000000LL #define Mod 1000000007LL using namespace std; int N,M,ans; lld T; lld a[100002]; lld s[1002][1002][2],e[1002][1002][2]; bool d[1002][1002][2]; bool can(lld X){ X *= T; X %= Mod; for(int i=1; i<=M; i++) for(int j=M; j<=N; j++) for(int k=0; k<2; k++){ d[i][j][k] = false; s[i][j][k] = Mod; e[i][j][k] = 0; } d[M][M][0] = true; s[M][M][0] = e[M][M][0] = a[M]; for(int i=1; i<=N-1; i++){ for(int j=max(1,M-i); j+i<=N; j++){ for(int k=0; k<2; k++){ int x,y; lld now,cnt = i; if(k == 0) now = a[j]; else now = a[j+i]; if(k == 0){ x = j+1; y = j+i; }else{ x = j; y = j+i-1; } for(int t=0; t<2; t++){ if(!d[x][y][t]) continue; if(max(s[x][y][t]-X,now-cnt*X) <= min(e[x][y][t]+X,now+cnt*X)){ d[j][j+i][k] = true; s[j][j+i][k] = min(s[j][j+i][k],max(s[x][y][t]-X,now-cnt*X)); e[j][j+i][k] = max(e[j][j+i][k],min(e[x][y][t]+X,now+cnt*X)); s[j][j+i][k] = max(s[j][j+i][k],(lld)0); e[j][j+i][k] = min(e[j][j+i][k],Mod); } } } } } return (d[1][N][0]|d[1][N][1]); } int main(){ scanf("%d %d %lld",&N,&M,&T); for(int i=1; i<=N; i++){ scanf("%lld",&a[i]); } int l,r; l = 0; r = a[N]; while(l <= r){ int m = (l+r)/2; if(can(m)){ ans = m; r = m-1; }else l = m+1; } can(ans); printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 36136 KB | Output is correct |
2 | Correct | 0 ms | 36136 KB | Output is correct |
3 | Correct | 0 ms | 36136 KB | Output is correct |
4 | Correct | 0 ms | 36136 KB | Output is correct |
5 | Correct | 0 ms | 36136 KB | Output is correct |
6 | Correct | 0 ms | 36136 KB | Output is correct |
7 | Correct | 0 ms | 36136 KB | Output is correct |
8 | Correct | 0 ms | 36136 KB | Output is correct |
9 | Correct | 0 ms | 36136 KB | Output is correct |
10 | Correct | 0 ms | 36136 KB | Output is correct |
11 | Correct | 0 ms | 36136 KB | Output is correct |
12 | Correct | 0 ms | 36136 KB | Output is correct |
13 | Correct | 0 ms | 36136 KB | Output is correct |
14 | Correct | 0 ms | 36136 KB | Output is correct |
15 | Correct | 0 ms | 36136 KB | Output is correct |
16 | Correct | 0 ms | 36136 KB | Output is correct |
17 | Correct | 0 ms | 36136 KB | Output is correct |
18 | Correct | 0 ms | 36136 KB | Output is correct |
19 | Correct | 0 ms | 36136 KB | Output is correct |
20 | Correct | 0 ms | 36136 KB | Output is correct |
21 | Correct | 0 ms | 36136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 36136 KB | Output is correct |
2 | Correct | 0 ms | 36136 KB | Output is correct |
3 | Correct | 0 ms | 36136 KB | Output is correct |
4 | Correct | 0 ms | 36136 KB | Output is correct |
5 | Correct | 0 ms | 36136 KB | Output is correct |
6 | Correct | 0 ms | 36136 KB | Output is correct |
7 | Correct | 0 ms | 36136 KB | Output is correct |
8 | Correct | 0 ms | 36136 KB | Output is correct |
9 | Correct | 0 ms | 36136 KB | Output is correct |
10 | Correct | 0 ms | 36136 KB | Output is correct |
11 | Correct | 0 ms | 36136 KB | Output is correct |
12 | Correct | 0 ms | 36136 KB | Output is correct |
13 | Correct | 0 ms | 36136 KB | Output is correct |
14 | Correct | 0 ms | 36136 KB | Output is correct |
15 | Correct | 0 ms | 36136 KB | Output is correct |
16 | Correct | 0 ms | 36136 KB | Output is correct |
17 | Correct | 0 ms | 36136 KB | Output is correct |
18 | Correct | 0 ms | 36136 KB | Output is correct |
19 | Correct | 0 ms | 36136 KB | Output is correct |
20 | Correct | 0 ms | 36136 KB | Output is correct |
21 | Correct | 0 ms | 36136 KB | Output is correct |
22 | Correct | 203 ms | 36136 KB | Output is correct |
23 | Correct | 123 ms | 36136 KB | Output is correct |
24 | Correct | 119 ms | 36136 KB | Output is correct |
25 | Correct | 196 ms | 36136 KB | Output is correct |
26 | Correct | 276 ms | 36136 KB | Output is correct |
27 | Correct | 299 ms | 36136 KB | Output is correct |
28 | Correct | 346 ms | 36136 KB | Output is correct |
29 | Correct | 296 ms | 36136 KB | Output is correct |
30 | Correct | 209 ms | 36136 KB | Output is correct |
31 | Correct | 233 ms | 36136 KB | Output is correct |
32 | Correct | 346 ms | 36136 KB | Output is correct |
33 | Correct | 386 ms | 36136 KB | Output is correct |
34 | Correct | 163 ms | 36136 KB | Output is correct |
35 | Correct | 303 ms | 36136 KB | Output is correct |
36 | Correct | 219 ms | 36136 KB | Output is correct |
37 | Correct | 206 ms | 36136 KB | Output is correct |
38 | Correct | 266 ms | 36136 KB | Output is correct |
39 | Correct | 56 ms | 36136 KB | Output is correct |
40 | Correct | 29 ms | 36136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 36136 KB | Output is correct |
2 | Correct | 0 ms | 36136 KB | Output is correct |
3 | Correct | 0 ms | 36136 KB | Output is correct |
4 | Correct | 0 ms | 36136 KB | Output is correct |
5 | Correct | 0 ms | 36136 KB | Output is correct |
6 | Correct | 0 ms | 36136 KB | Output is correct |
7 | Correct | 0 ms | 36136 KB | Output is correct |
8 | Correct | 0 ms | 36136 KB | Output is correct |
9 | Correct | 0 ms | 36136 KB | Output is correct |
10 | Correct | 0 ms | 36136 KB | Output is correct |
11 | Correct | 0 ms | 36136 KB | Output is correct |
12 | Correct | 0 ms | 36136 KB | Output is correct |
13 | Correct | 0 ms | 36136 KB | Output is correct |
14 | Correct | 0 ms | 36136 KB | Output is correct |
15 | Correct | 0 ms | 36136 KB | Output is correct |
16 | Correct | 0 ms | 36136 KB | Output is correct |
17 | Correct | 0 ms | 36136 KB | Output is correct |
18 | Correct | 0 ms | 36136 KB | Output is correct |
19 | Correct | 0 ms | 36136 KB | Output is correct |
20 | Correct | 0 ms | 36136 KB | Output is correct |
21 | Correct | 0 ms | 36136 KB | Output is correct |
22 | Correct | 203 ms | 36136 KB | Output is correct |
23 | Correct | 123 ms | 36136 KB | Output is correct |
24 | Correct | 119 ms | 36136 KB | Output is correct |
25 | Correct | 196 ms | 36136 KB | Output is correct |
26 | Correct | 276 ms | 36136 KB | Output is correct |
27 | Correct | 299 ms | 36136 KB | Output is correct |
28 | Correct | 346 ms | 36136 KB | Output is correct |
29 | Correct | 296 ms | 36136 KB | Output is correct |
30 | Correct | 209 ms | 36136 KB | Output is correct |
31 | Correct | 233 ms | 36136 KB | Output is correct |
32 | Correct | 346 ms | 36136 KB | Output is correct |
33 | Correct | 386 ms | 36136 KB | Output is correct |
34 | Correct | 163 ms | 36136 KB | Output is correct |
35 | Correct | 303 ms | 36136 KB | Output is correct |
36 | Correct | 219 ms | 36136 KB | Output is correct |
37 | Correct | 206 ms | 36136 KB | Output is correct |
38 | Correct | 266 ms | 36136 KB | Output is correct |
39 | Correct | 56 ms | 36136 KB | Output is correct |
40 | Correct | 29 ms | 36136 KB | Output is correct |
41 | Runtime error | 93 ms | 36136 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
42 | Halted | 0 ms | 0 KB | - |