#include <bits/stdc++.h>
using namespace std;
long long dp[2][2000001],arr[301],br = 1e6,n,m;
signed main(){
cin>>m>>n;
for(int i = 0;i<2*m+1;i++){
cin>>arr[i];
}
memset(dp,-1,sizeof dp);
for(int i = 2*m+1;i>=0;i--){
for(int j = 0;j<=2e6;j++){
if(i==2*m+1){
if(j==n+br){
dp[i&1][j] = 0;
}else{
dp[i&1][j] = -1e18;
}
continue;
}
long long ans = -1e18;
for(int e = 0;e<=arr[i];e++){
ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
}
dp[i&1][j] = ans;
}
}
long long vl = dp[0][1000000];
if(vl<0)cout<<"impossible\n";
else cout<<vl<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31576 KB |
Output is correct |
2 |
Correct |
36 ms |
31720 KB |
Output is correct |
3 |
Correct |
22 ms |
31576 KB |
Output is correct |
4 |
Correct |
152 ms |
31720 KB |
Output is correct |
5 |
Correct |
4195 ms |
31724 KB |
Output is correct |
6 |
Correct |
4459 ms |
31728 KB |
Output is correct |
7 |
Correct |
1930 ms |
31720 KB |
Output is correct |
8 |
Correct |
4244 ms |
31728 KB |
Output is correct |
9 |
Runtime error |
137 ms |
63824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31576 KB |
Output is correct |
2 |
Correct |
36 ms |
31720 KB |
Output is correct |
3 |
Correct |
22 ms |
31576 KB |
Output is correct |
4 |
Correct |
152 ms |
31720 KB |
Output is correct |
5 |
Correct |
4195 ms |
31724 KB |
Output is correct |
6 |
Correct |
4459 ms |
31728 KB |
Output is correct |
7 |
Correct |
1930 ms |
31720 KB |
Output is correct |
8 |
Correct |
4244 ms |
31728 KB |
Output is correct |
9 |
Runtime error |
137 ms |
63824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
31724 KB |
Output is correct |
2 |
Runtime error |
134 ms |
64080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
31724 KB |
Output is correct |
2 |
Runtime error |
134 ms |
64080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
31724 KB |
Output is correct |
2 |
Runtime error |
134 ms |
64080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31576 KB |
Output is correct |
2 |
Correct |
36 ms |
31720 KB |
Output is correct |
3 |
Correct |
22 ms |
31576 KB |
Output is correct |
4 |
Correct |
152 ms |
31720 KB |
Output is correct |
5 |
Correct |
4195 ms |
31724 KB |
Output is correct |
6 |
Correct |
4459 ms |
31728 KB |
Output is correct |
7 |
Correct |
1930 ms |
31720 KB |
Output is correct |
8 |
Correct |
4244 ms |
31728 KB |
Output is correct |
9 |
Runtime error |
137 ms |
63824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
31724 KB |
Output is correct |
2 |
Runtime error |
134 ms |
64080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31576 KB |
Output is correct |
2 |
Correct |
36 ms |
31720 KB |
Output is correct |
3 |
Correct |
22 ms |
31576 KB |
Output is correct |
4 |
Correct |
152 ms |
31720 KB |
Output is correct |
5 |
Correct |
4195 ms |
31724 KB |
Output is correct |
6 |
Correct |
4459 ms |
31728 KB |
Output is correct |
7 |
Correct |
1930 ms |
31720 KB |
Output is correct |
8 |
Correct |
4244 ms |
31728 KB |
Output is correct |
9 |
Runtime error |
137 ms |
63824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
31724 KB |
Output is correct |
2 |
Runtime error |
134 ms |
64080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
31576 KB |
Output is correct |
2 |
Correct |
36 ms |
31720 KB |
Output is correct |
3 |
Correct |
22 ms |
31576 KB |
Output is correct |
4 |
Correct |
152 ms |
31720 KB |
Output is correct |
5 |
Correct |
4195 ms |
31724 KB |
Output is correct |
6 |
Correct |
4459 ms |
31728 KB |
Output is correct |
7 |
Correct |
1930 ms |
31720 KB |
Output is correct |
8 |
Correct |
4244 ms |
31728 KB |
Output is correct |
9 |
Runtime error |
137 ms |
63824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |