#include <bits/stdc++.h>
using namespace std;
short dp[2][2000001],arr[301];
int br = 1e6 , n , m;
signed main(){
cin>>m>>n;
for(int i = 0;i<2*m+1;i++){
cin>>arr[i];
}
int vl = -30001;
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] = -vl;
}
continue;
}
int ans = -vl;
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 vll = dp[0][1000000];
if(vll<0)cout<<"impossible\n";
else cout<<vll<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
8236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
8236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
8236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
8236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
8236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |