#include <stdio.h>
int dyn[101][10001];
int max(int a,int b) {
return (a>b)?a:b;
}
int main()
{
int n,m;
int i,j;
int memo[101],cost[101];
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++) scanf("%d",&memo[i]);
for(i=1;i<=n;i++) scanf("%d",&cost[i]);
for(i=1;i<=n;i++){
for(j=0;j<cost[i];j++) dyn[i][j]=dyn[i-1][j];
for(j=cost[i];j<=10000;j++){
dyn[i][j]=max(dyn[i-1][j],dyn[i-1][j-cost[i]]+memo[i]);
}
}
for(i=0;i<=10000;i++) if(dyn[n][i]>=m) break;
printf("%d",i);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
0 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
6 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
0 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
0 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
6 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
0 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
6 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
0 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
6 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5032 KB |
Output is correct |
2 |
Correct |
0 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
4 ms |
5032 KB |
Output is correct |
5 |
Correct |
0 ms |
5032 KB |
Output is correct |
6 |
Correct |
0 ms |
5032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5032 KB |
Output is correct |
2 |
Correct |
4 ms |
5032 KB |
Output is correct |
3 |
Correct |
0 ms |
5032 KB |
Output is correct |
4 |
Correct |
4 ms |
5032 KB |
Output is correct |