# include <stdio.h>
# include <iostream>
# include <algorithm>
using namespace std;
long long a[10000000],b[10000000],c[10000000];
int main()
{
long long t,m;
long long i,j;
cin>>t>>m;
for(i=1;i<=m;i++)
{
cin>>a[i]>>b[i];
}
for(i=1;i<=m;i++)
{
for(j=a[i];j<=t;j++)
{
c[j]=max(c[j],c[j-a[i]]+b[i]);//动态转移方程;
}
}
cout<<c[t];
}
09-26
07-31
1530
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-27
590
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)