https://drive.google.com/file/d/1hT7KMovO2nfeEYPRp-BQCEibM4UaBVMo/view
#include <bits/stdc++.h>
#define hieuhfgr ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define gcd __gcd
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define inputfile "BOOKS.inp"
#define outputfile "BOOKS.out"
#define file freopen(inputfile, "r", stdin);freopen(outputfile, "w", stdout)
using namespace std;
int main(){
hieuhfgr;
file;
int n;
int v[10001], w[10001];
int x;
cin >> n >> x;
for(int i=1;i<= n;i++) cin >> w[i];
for(int i=1;i<= n;i++) cin >> v[i];
int f[n+1][x+1];
memset(f, 0, sizeof(f));
for (int j=1;j <= x;j++) {
for (int i=1;i<= n;i++) {
f[i][j] = f[i-1][j];
if (j > w[i]) {
f[i][j] = max(f[i][j], f[i-1][j- w[i]] + v[i]);
}
}
}
cout << f[n][x];
return 0;
}