#include <memory.h>
#define max(a,b) a>b?a:b
int main(){
int i, j, N, M, m[101], c[101], *dp, SZ = 1;
scanf("%d%d",&N, &M);
for(i=0; i < N; ++i) scanf("%d",&m[i]);
for(i=0; i < N; ++i) scanf("%d",&c[i]), SZ += c[i];
dp = (int*)malloc(SZ+110);
for(i=1; i <= SZ; ++i) dp[i] = -1;
for(i=0; i < N; ++i){
for(j=SZ; j >= 0; --j){
if( dp[j] >= 0 )
dp[ j+c[i] ] = max( dp[j+c[i]], dp[j]+m[i] );
}
}
for(i=0; i <= SZ; ++i)
if( dp[i] >= M ) break;
printf("%d", i);
return 0;
}
Compilation message
app.cpp: In function ‘int main()’:
app.cpp:5:21: error: ‘scanf’ was not declared in this scope
scanf("%d%d",&N, &M);
^
app.cpp:8:26: error: ‘malloc’ was not declared in this scope
dp = (int*)malloc(SZ+110);
^
app.cpp:18:16: error: ‘printf’ was not declared in this scope
printf("%d", i);
^