#include <cstdio>
using namespace std;
int T[100][10001];
int mem[100], cost[100];
int N, memto;
int main() {
int i, j;
scanf("%d %d", &N, &memto);
for (i=0; i<N; ++i) {
scanf("%d", &mem[i]);
}
for (i=0; i<N; ++i) {
scanf("%d", &cost[i]);
}
for(j = 10000; j >= cost[0]; j--) {
T[0][j] = mem[0];
}
for (i=1; i<N; ++i) {
for (j = 0; j < cost[i]; j++) T[i][j] = T[i - 1][j];
for (j=cost[i]; j<=10000; ++j) {
T[i][j] = T[i - 1][j];
if (T[i][j] < T[i - 1][j - cost[i]] + mem[i]) {
T[i][j] = T[i - 1][j - cost[i]] + mem[i];
}
}
}
for (i=0; i<=10001; ++i) {
if (T[N - 1][i] >= memto) {
break;
}
}
printf("%d\n", i);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
6 |
Correct |
0 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
6 |
Correct |
0 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
6 |
Correct |
0 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
6 |
Correct |
0 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
0 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
4996 KB |
Output is correct |
6 |
Correct |
4 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4996 KB |
Output is correct |
2 |
Correct |
4 ms |
4996 KB |
Output is correct |
3 |
Correct |
0 ms |
4996 KB |
Output is correct |
4 |
Correct |
0 ms |
4996 KB |
Output is correct |