mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1104.cpp
This commit is contained in:
parent
8cb3165f53
commit
094b4b52eb
28
VIJOS/1104.cpp
Normal file
28
VIJOS/1104.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
#define MAXN 1005
|
||||
int dp[MAXN];
|
||||
int cost[MAXN];
|
||||
int value[MAXN];
|
||||
int main()
|
||||
{
|
||||
int t,m;
|
||||
scanf("%d %d",&t,&m);
|
||||
for(int i=0;i<m;i++)
|
||||
{
|
||||
scanf("%d %d",&cost[i],&value[i]);
|
||||
}
|
||||
for(int i=0;i<m;i++)
|
||||
{
|
||||
for(int j=t;j>0;j--)
|
||||
{
|
||||
if(j-cost[i]>=0)
|
||||
dp[j]=max(dp[j],dp[j-cost[i]]+value[i]);
|
||||
}
|
||||
}
|
||||
printf("%d\n",dp[t]);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user