#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int n,m;
int w[210],c[210];
int f[210];
int main()
{
freopen("package.in","r",stdin);
freopen("package.out","w",stdout);
scanf("%d%d",&m,&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&w[i],&c[i]);
for(int i=1;i<=n;i++)
for(int j=m;j>=w[i];j--)
{
f[j]=max(f[j],f[j-w[i]]+c[i]);
}
printf("%d",f[m]);
fclose(stdin);fclose(stdout);
return 0;
}
嘎嘎,第一篇