#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e18;
int M, L, A[210], D[1200010];
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>M>>L;
for(int i=0; i<=2*M; i++) cin>>A[i];
for(int j=0; j<=1200000; j++) D[j]=-INF;
D[600000]=0;
for(int i=-M; i<=M; i++) {
while(A[i+M]--) {
if(i>0) for(int j=1200000; j>=i; j--) D[j]=max(D[j], D[j-i]+1);
else for(int j=0; j<=1200000; j++) D[j]=max(D[j], D[j-i]+1);
}
}
if(D[600000+L]>=0) cout<<D[600000+L]<<"\n";
else cout<<"impossible";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9820 KB |
Output is correct |
2 |
Correct |
12 ms |
9820 KB |
Output is correct |
3 |
Correct |
8 ms |
9820 KB |
Output is correct |
4 |
Correct |
68 ms |
9828 KB |
Output is correct |
5 |
Runtime error |
2031 ms |
19536 KB |
Execution killed with signal 7 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9820 KB |
Output is correct |
2 |
Correct |
12 ms |
9820 KB |
Output is correct |
3 |
Correct |
8 ms |
9820 KB |
Output is correct |
4 |
Correct |
68 ms |
9828 KB |
Output is correct |
5 |
Runtime error |
2031 ms |
19536 KB |
Execution killed with signal 7 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
9816 KB |
Output is correct |
2 |
Execution timed out |
5069 ms |
9820 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
9816 KB |
Output is correct |
2 |
Execution timed out |
5069 ms |
9820 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
9816 KB |
Output is correct |
2 |
Execution timed out |
5069 ms |
9820 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9820 KB |
Output is correct |
2 |
Correct |
12 ms |
9820 KB |
Output is correct |
3 |
Correct |
8 ms |
9820 KB |
Output is correct |
4 |
Correct |
68 ms |
9828 KB |
Output is correct |
5 |
Runtime error |
2031 ms |
19536 KB |
Execution killed with signal 7 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
9816 KB |
Output is correct |
2 |
Execution timed out |
5069 ms |
9820 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9820 KB |
Output is correct |
2 |
Correct |
12 ms |
9820 KB |
Output is correct |
3 |
Correct |
8 ms |
9820 KB |
Output is correct |
4 |
Correct |
68 ms |
9828 KB |
Output is correct |
5 |
Runtime error |
2031 ms |
19536 KB |
Execution killed with signal 7 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
9816 KB |
Output is correct |
2 |
Execution timed out |
5069 ms |
9820 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
9820 KB |
Output is correct |
2 |
Correct |
12 ms |
9820 KB |
Output is correct |
3 |
Correct |
8 ms |
9820 KB |
Output is correct |
4 |
Correct |
68 ms |
9828 KB |
Output is correct |
5 |
Runtime error |
2031 ms |
19536 KB |
Execution killed with signal 7 |
6 |
Halted |
0 ms |
0 KB |
- |