1 1000 5 800 2 400 5 300 5 400 3 200 2
3900
#include#include using namespace std; int v[26],w[26]; int dp[30005]; int max(int a,int b) {return a>b?a:b;} int main() { int N,n,m,i,j; cin>>N; while(N--) { cin>>n>>m; for(i=0;i >v[i]>>w[i]; memset(dp,0,sizeof(dp)); for(i=0;i =v[i];j--) dp[j]=max(dp[j],dp[j-v[i]]+w[i]*v[i]); cout<