/*
ID: Jang Lawrence
PROG: inflate
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#define X first
#define Y second
#define sqr(a) ((a)*(a))
using namespace std;
typedef long long lng;
int m,n;
int dp[11000];
int w[11111],v[11111];
int main()
{
#ifndef DEBUG
freopen("inflate.in","r",stdin);
freopen("inflate.out","w",stdout);
#endif
scanf("%d%d",&m,&n);
for(int i=0;i<n;++i)
scanf("%d%d",v+i,w+i);
memset(dp,0,sizeof(dp));
for(int i=0;i<n;++i)
for(int j=w[i];j<=m;++j)
dp[j]=(dp[j]<dp[j-w[i]]+v[i])?dp[j-w[i]]+v[i]:dp[j];
printf("%d\n",dp[m]);
return 0;
}
USACO:Score Inflation
最新推荐文章于 2023-07-06 19:54:23 发布