#include<iostream>//n个物品,各有价格和体积,背包容量V,求装满背包的最大价值装法 using namespace std; #define maxn 30 int a[maxn],b[maxn]; int n,v,maxv=0; void DFS(int idex, int suma, int sumb) { if (idex == n)return; DFS(idex + 1, suma, sumb); if (suma + a[idex] <= v) { if (sumb +b[idex] >maxv) maxv =sumb + b[idex]; DFS(idex + 1, suma + a[idex], sumb + b[idex]); } } int main() { cin >> n >> v; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; DFS(0, 0, 0); cout << maxv <<endl; return 0; }