直接板子题
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 30010,M=26;
int f[M][N];
int w[M],v[N];
int n,m;
int main()
{
cin>>n>>m;
for (int i=1;i<=m;i++) cin>>v[i]>>w[i];
for (int i=1;i<=m;i++)
for (int j=0;j<=n;j++)
{
f[i][j]=f[i-1][j];
if (j>=v[i]) f[i][j]=max(f[i][j],f[i-1][j-v[i]]+v[i]*w[i]);
}
cout<<f[m][n]<<endl;
return 0;
}