#include<stdio.h>
#include<stdlib.h>
int dp[102][10002];
int main()
{
int i, j, n, need, m[102][4];
scanf("%d %d",&n,&need);
for(i=1 ; i<=n ; i++) scanf("%d",&m[i][1]);
for(i=1 ; i<=n ; i++) scanf("%d",&m[i][2]);
for(i=1 ; i<=n ; i++)
{
for(j=1 ; j<=10000 ; j++) dp[i][j]=dp[i-1][j];
for(j=1 ; j<=10000 ; j++)
{
if(j-m[i][2]>=0)
{
if(dp[i][j]<dp[i-1][j-m[i][2]]+m[i][1]) dp[i][j]=dp[i-1][j-m[i][2]]+m[i][1];
}
}
}
for(j=1 ; j<=10000 ; j++)
{
for(i=1 ; i<=n ; i++)
{
if(dp[i][j]>=need)
{
printf("%d",j);
exit(1);
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5068 KB |
Output is correct |
2 |
Correct |
0 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
0 ms |
5068 KB |
Output is correct |
5 |
Correct |
0 ms |
5068 KB |
Output is correct |
6 |
Correct |
0 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5068 KB |
Output is correct |
2 |
Correct |
0 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
0 ms |
5068 KB |
Output is correct |
5 |
Correct |
0 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
5068 KB |
Output is correct |
2 |
Correct |
0 ms |
5068 KB |
Output is correct |
3 |
Correct |
2 ms |
5068 KB |
Output is correct |
4 |
Correct |
2 ms |
5068 KB |
Output is correct |
5 |
Correct |
2 ms |
5068 KB |
Output is correct |
6 |
Correct |
2 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5068 KB |
Output is correct |
2 |
Correct |
0 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
0 ms |
5068 KB |
Output is correct |
5 |
Correct |
0 ms |
5068 KB |
Output is correct |
6 |
Correct |
0 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5068 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
0 ms |
5068 KB |
Output is correct |
5 |
Correct |
0 ms |
5068 KB |
Output is correct |
6 |
Correct |
0 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5068 KB |
Output is correct |
2 |
Correct |
3 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
0 ms |
5068 KB |
Output is correct |
5 |
Correct |
0 ms |
5068 KB |
Output is correct |
6 |
Correct |
0 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5068 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
0 ms |
5068 KB |
Output is correct |
4 |
Correct |
4 ms |
5068 KB |
Output is correct |