p2725 Stamps

时间:2020-12-16 08:12:37

背包。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=;
int dp[SZ],arr[SZ]; int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int k,n;
cin>>k>>n;
for(int i=;i<=n;++i)cin>>arr[i];
for(int i=;i<SZ;++i)dp[i]=INF;
dp[]=;
for(int i=;i<=n;++i)
{
for(int j=;j<=SZ;++j)
{
if(j>=arr[i]&&dp[j-arr[i]]!=INF)
{
dp[j]=min(dp[j],dp[j-arr[i]]+);
}
}
}
int res=;
for(int i=;i<SZ;++i)
{
//cout<<i<<endl;
if(dp[i]>k)
{
cout<<i-<<endl;
return ;
}
}
}
return ;
}