求助,#1-3AC,#4-10RE。。。
代码:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int T,M,t[111],w[111],f[111];
int main(){
cin>>T>>M;
for(int i=0;i<M;i++)
cin>>t[i]>>w[i];
for(int i=0;i<M;i++)
for(int j=T;j>=t[i];j--)
if(j>=t[i])f[j]=max(f[j],f[j-t[i]]+w[i]);
cout<<f[T];
return 0;
}