Lang:G++
Edit123456789101112131415#include <iostream>using namespace std;int dp[100010]={0};int main(){int n,m,need,v;cin>>n>>m;for(int i=1;i<=n;i++){cin>>need>>v;for(int t=m;t>=need;t--) if((dp[t-need]+v)>dp[t])dp[t]=dp[t-need]+v;}cout<<dp[m]<<endl;return 0;}