#include<stdio.h>
#include<algorithm>
using namespace std;
int D[105][10500];
int N,M,m[105],c[105];
int s;
int ans=100000000;
int input();
int solve();
int output();
int input(){
scanf("%d %d",&N,&M);
for(int i=1;i<=N;i++)scanf("%d",&m[i]);
for(int i=1;i<=N;i++){scanf("%d",&c[i]);s+=c[i];}
return 0;
}
int solve(){
for(int i=1;i<=N;i++){
for(int j=1;j<=s;j++){
if(j<c[i]){
D[i][j]=D[i-1][j];
}
else
D[i][j]=max(D[i-1][j-c[i]]+m[i],D[i-1][j]);
if(D[i][j]>=M) ans=min(ans,j);
}
}
return 0;
}
int output(){
printf("%d",ans);
return 0;
}
int main(){
input();
solve();
output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
6 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
6 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
6 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
6 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |
5 |
Correct |
0 ms |
5396 KB |
Output is correct |
6 |
Correct |
0 ms |
5396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5396 KB |
Output is correct |
2 |
Correct |
0 ms |
5396 KB |
Output is correct |
3 |
Correct |
0 ms |
5396 KB |
Output is correct |
4 |
Correct |
0 ms |
5396 KB |
Output is correct |