#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#define int long long
using namespace std;
const int M = 300 + 11;
const int X = M * M;
const int INF = 1LL << 60;
int a[M * 2];
int s[M * 2];
int dp[M * 2][X];
int32_t main(){
int m, L; cin >> m >> L;
for(int i = 0; i <= m * 2; i++) cin >> a[i];
int ans = a[m];
for(int i = m + 1; i <= m * 2; i++) s[i] = min(L, s[i - 1] + (i - m) * a[i]);
for(int i = m; i <= m * 2; i++)
fill(dp[i], dp[i] + X, -INF);
dp[m][0] = 0;
for(int i = m + 1; i <= m * 2; i++){
for(int j = 0; j <= m * (i - 1 - m); j++){
for(int k = ((s[i] - s[i - 1] + j) % (i - m) + (i - m)) % (i - m); k <= m * (i - m); k += (i - m)){
int vj = s[i - 1] - j, vk = s[i] - k;
if(vj > vk) break;
if((vk - vj) / (i - m) > a[i]) continue;
dp[i][k] = max(dp[i][k], dp[i - 1][j] + (vk - vj) / (i - m));
}
}
}
if(s[m * 2] < L || L < 0){
cout << "impossible" << endl;
return 0;
}
if(dp[m * 2][0] < 0){
cout << "impossible" << endl;
}else{
cout << ans + dp[m * 2][0] << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8660 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
11 ms |
23684 KB |
Output is correct |
4 |
Correct |
13 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23696 KB |
Output is correct |
6 |
Correct |
11 ms |
23764 KB |
Output is correct |
7 |
Correct |
10 ms |
23796 KB |
Output is correct |
8 |
Correct |
10 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23704 KB |
Output is correct |
10 |
Correct |
11 ms |
23752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8660 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
11 ms |
23684 KB |
Output is correct |
4 |
Correct |
13 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23696 KB |
Output is correct |
6 |
Correct |
11 ms |
23764 KB |
Output is correct |
7 |
Correct |
10 ms |
23796 KB |
Output is correct |
8 |
Correct |
10 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23704 KB |
Output is correct |
10 |
Correct |
11 ms |
23752 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8660 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
11 ms |
23684 KB |
Output is correct |
4 |
Correct |
13 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23696 KB |
Output is correct |
6 |
Correct |
11 ms |
23764 KB |
Output is correct |
7 |
Correct |
10 ms |
23796 KB |
Output is correct |
8 |
Correct |
10 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23704 KB |
Output is correct |
10 |
Correct |
11 ms |
23752 KB |
Output is correct |
11 |
Correct |
4 ms |
8532 KB |
Output is correct |
12 |
Correct |
12 ms |
23716 KB |
Output is correct |
13 |
Correct |
11 ms |
23804 KB |
Output is correct |
14 |
Correct |
11 ms |
23764 KB |
Output is correct |
15 |
Correct |
12 ms |
23684 KB |
Output is correct |
16 |
Correct |
11 ms |
23764 KB |
Output is correct |
17 |
Correct |
10 ms |
23720 KB |
Output is correct |
18 |
Correct |
11 ms |
23776 KB |
Output is correct |
19 |
Correct |
10 ms |
23712 KB |
Output is correct |
20 |
Correct |
11 ms |
23764 KB |
Output is correct |
21 |
Correct |
22 ms |
38832 KB |
Output is correct |
22 |
Correct |
25 ms |
38940 KB |
Output is correct |
23 |
Correct |
34 ms |
38812 KB |
Output is correct |
24 |
Correct |
31 ms |
38868 KB |
Output is correct |
25 |
Correct |
34 ms |
38936 KB |
Output is correct |
26 |
Correct |
26 ms |
38944 KB |
Output is correct |
27 |
Correct |
23 ms |
38936 KB |
Output is correct |
28 |
Correct |
31 ms |
38868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8660 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
11 ms |
23684 KB |
Output is correct |
4 |
Correct |
13 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23696 KB |
Output is correct |
6 |
Correct |
11 ms |
23764 KB |
Output is correct |
7 |
Correct |
10 ms |
23796 KB |
Output is correct |
8 |
Correct |
10 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23704 KB |
Output is correct |
10 |
Correct |
11 ms |
23752 KB |
Output is correct |
11 |
Correct |
4 ms |
8532 KB |
Output is correct |
12 |
Correct |
12 ms |
23716 KB |
Output is correct |
13 |
Correct |
11 ms |
23804 KB |
Output is correct |
14 |
Correct |
11 ms |
23764 KB |
Output is correct |
15 |
Correct |
12 ms |
23684 KB |
Output is correct |
16 |
Correct |
11 ms |
23764 KB |
Output is correct |
17 |
Correct |
10 ms |
23720 KB |
Output is correct |
18 |
Correct |
11 ms |
23776 KB |
Output is correct |
19 |
Correct |
10 ms |
23712 KB |
Output is correct |
20 |
Correct |
11 ms |
23764 KB |
Output is correct |
21 |
Correct |
22 ms |
38832 KB |
Output is correct |
22 |
Correct |
25 ms |
38940 KB |
Output is correct |
23 |
Correct |
34 ms |
38812 KB |
Output is correct |
24 |
Correct |
31 ms |
38868 KB |
Output is correct |
25 |
Correct |
34 ms |
38936 KB |
Output is correct |
26 |
Correct |
26 ms |
38944 KB |
Output is correct |
27 |
Correct |
23 ms |
38936 KB |
Output is correct |
28 |
Correct |
31 ms |
38868 KB |
Output is correct |
29 |
Correct |
3 ms |
8532 KB |
Output is correct |
30 |
Correct |
12 ms |
23696 KB |
Output is correct |
31 |
Correct |
11 ms |
23764 KB |
Output is correct |
32 |
Correct |
10 ms |
23764 KB |
Output is correct |
33 |
Correct |
13 ms |
23764 KB |
Output is correct |
34 |
Correct |
10 ms |
23764 KB |
Output is correct |
35 |
Correct |
11 ms |
23764 KB |
Output is correct |
36 |
Correct |
13 ms |
23768 KB |
Output is correct |
37 |
Correct |
12 ms |
23708 KB |
Output is correct |
38 |
Correct |
12 ms |
23676 KB |
Output is correct |
39 |
Correct |
23 ms |
38944 KB |
Output is correct |
40 |
Correct |
24 ms |
38900 KB |
Output is correct |
41 |
Correct |
34 ms |
38888 KB |
Output is correct |
42 |
Correct |
32 ms |
38840 KB |
Output is correct |
43 |
Correct |
34 ms |
38916 KB |
Output is correct |
44 |
Correct |
27 ms |
38916 KB |
Output is correct |
45 |
Correct |
23 ms |
38944 KB |
Output is correct |
46 |
Correct |
31 ms |
38920 KB |
Output is correct |
47 |
Correct |
159 ms |
76708 KB |
Output is correct |
48 |
Correct |
159 ms |
76776 KB |
Output is correct |
49 |
Correct |
328 ms |
76776 KB |
Output is correct |
50 |
Correct |
243 ms |
76668 KB |
Output is correct |
51 |
Correct |
246 ms |
76868 KB |
Output is correct |
52 |
Correct |
236 ms |
76772 KB |
Output is correct |
53 |
Correct |
160 ms |
76780 KB |
Output is correct |
54 |
Correct |
271 ms |
76768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8660 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
11 ms |
23684 KB |
Output is correct |
4 |
Correct |
13 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23696 KB |
Output is correct |
6 |
Correct |
11 ms |
23764 KB |
Output is correct |
7 |
Correct |
10 ms |
23796 KB |
Output is correct |
8 |
Correct |
10 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23704 KB |
Output is correct |
10 |
Correct |
11 ms |
23752 KB |
Output is correct |
11 |
Correct |
4 ms |
8532 KB |
Output is correct |
12 |
Correct |
12 ms |
23716 KB |
Output is correct |
13 |
Correct |
11 ms |
23804 KB |
Output is correct |
14 |
Correct |
11 ms |
23764 KB |
Output is correct |
15 |
Correct |
12 ms |
23684 KB |
Output is correct |
16 |
Correct |
11 ms |
23764 KB |
Output is correct |
17 |
Correct |
10 ms |
23720 KB |
Output is correct |
18 |
Correct |
11 ms |
23776 KB |
Output is correct |
19 |
Correct |
10 ms |
23712 KB |
Output is correct |
20 |
Correct |
11 ms |
23764 KB |
Output is correct |
21 |
Correct |
22 ms |
38832 KB |
Output is correct |
22 |
Correct |
25 ms |
38940 KB |
Output is correct |
23 |
Correct |
34 ms |
38812 KB |
Output is correct |
24 |
Correct |
31 ms |
38868 KB |
Output is correct |
25 |
Correct |
34 ms |
38936 KB |
Output is correct |
26 |
Correct |
26 ms |
38944 KB |
Output is correct |
27 |
Correct |
23 ms |
38936 KB |
Output is correct |
28 |
Correct |
31 ms |
38868 KB |
Output is correct |
29 |
Correct |
3 ms |
8532 KB |
Output is correct |
30 |
Correct |
12 ms |
23696 KB |
Output is correct |
31 |
Correct |
11 ms |
23764 KB |
Output is correct |
32 |
Correct |
10 ms |
23764 KB |
Output is correct |
33 |
Correct |
13 ms |
23764 KB |
Output is correct |
34 |
Correct |
10 ms |
23764 KB |
Output is correct |
35 |
Correct |
11 ms |
23764 KB |
Output is correct |
36 |
Correct |
13 ms |
23768 KB |
Output is correct |
37 |
Correct |
12 ms |
23708 KB |
Output is correct |
38 |
Correct |
12 ms |
23676 KB |
Output is correct |
39 |
Correct |
23 ms |
38944 KB |
Output is correct |
40 |
Correct |
24 ms |
38900 KB |
Output is correct |
41 |
Correct |
34 ms |
38888 KB |
Output is correct |
42 |
Correct |
32 ms |
38840 KB |
Output is correct |
43 |
Correct |
34 ms |
38916 KB |
Output is correct |
44 |
Correct |
27 ms |
38916 KB |
Output is correct |
45 |
Correct |
23 ms |
38944 KB |
Output is correct |
46 |
Correct |
31 ms |
38920 KB |
Output is correct |
47 |
Correct |
159 ms |
76708 KB |
Output is correct |
48 |
Correct |
159 ms |
76776 KB |
Output is correct |
49 |
Correct |
328 ms |
76776 KB |
Output is correct |
50 |
Correct |
243 ms |
76668 KB |
Output is correct |
51 |
Correct |
246 ms |
76868 KB |
Output is correct |
52 |
Correct |
236 ms |
76772 KB |
Output is correct |
53 |
Correct |
160 ms |
76780 KB |
Output is correct |
54 |
Correct |
271 ms |
76768 KB |
Output is correct |
55 |
Correct |
4 ms |
8532 KB |
Output is correct |
56 |
Correct |
12 ms |
23700 KB |
Output is correct |
57 |
Correct |
11 ms |
23760 KB |
Output is correct |
58 |
Correct |
11 ms |
23764 KB |
Output is correct |
59 |
Correct |
13 ms |
23796 KB |
Output is correct |
60 |
Correct |
10 ms |
23764 KB |
Output is correct |
61 |
Correct |
11 ms |
23796 KB |
Output is correct |
62 |
Correct |
11 ms |
23688 KB |
Output is correct |
63 |
Correct |
10 ms |
23776 KB |
Output is correct |
64 |
Correct |
11 ms |
23764 KB |
Output is correct |
65 |
Correct |
23 ms |
38936 KB |
Output is correct |
66 |
Correct |
25 ms |
38868 KB |
Output is correct |
67 |
Correct |
36 ms |
38924 KB |
Output is correct |
68 |
Correct |
32 ms |
38864 KB |
Output is correct |
69 |
Correct |
35 ms |
38932 KB |
Output is correct |
70 |
Correct |
28 ms |
38940 KB |
Output is correct |
71 |
Correct |
23 ms |
38940 KB |
Output is correct |
72 |
Correct |
31 ms |
38868 KB |
Output is correct |
73 |
Correct |
158 ms |
76772 KB |
Output is correct |
74 |
Correct |
160 ms |
76756 KB |
Output is correct |
75 |
Correct |
328 ms |
76772 KB |
Output is correct |
76 |
Correct |
244 ms |
76788 KB |
Output is correct |
77 |
Correct |
247 ms |
76772 KB |
Output is correct |
78 |
Correct |
236 ms |
76768 KB |
Output is correct |
79 |
Correct |
154 ms |
76684 KB |
Output is correct |
80 |
Correct |
268 ms |
76724 KB |
Output is correct |
81 |
Execution timed out |
5080 ms |
228172 KB |
Time limit exceeded |
82 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |