#include<iostream> #include<algorithm> usingnamespacestd; constint M = 1005; structPackage { int num[M]; int vlaue[M]; }; intmain() { Package pack; int F[M]; int N, V; cin >> N >> V; for (int i = 1; i <= N; i++) cin >> pack.num[i] >> pack.vlaue[i]; for (int i = 1; i <= N; i++) for (int j = V; j >= pack.num[i]; j--) F[j] = max(F[j], F[j - pack.num[i]] + pack.vlaue[i]); int res = 0; res = F[V]; cout << res << endl; return0; }