提交时间:2023-12-09 10:28:17
运行 ID: 114850
#include<bits/stdc++.h> #define int long long using namespace std; int a[100005],b[100005],dp[100005]; signed main(){ int t,m; cin>>t>>m; for (int i = 1;i <= m;i++){ cin>>a[i]>>b[i]; } for (int i = 1;i <= m;i++){ for (int j = a[i];j <= t;j++){ dp[j] = max(dp[j],dp[j - a[i]] + b[i]); } } cout<<"max="<<dp[t]<<endl; return 0; }