Information
- ID
- 1115
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 9
- Tags
- # Submissions
- 9
- Accepted
- 6
- Uploaded By
贴个代码
#include <iostream>
#include <cmath>
#include <algorithm>
#define QAQ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
const int N=105;
using namespace std;
int n,V,v[35],dp[35][200005];
int main(){
QAQ;
cin>>V>>n;
for(int i=1;i<=n;i++)
{
cin>>v[i];
for(int j=1;j<=V;j++)
{
if(j>=v[i])
dp[i][j]=max(dp[i-1][j-v[i]]+v[i],dp[i-1][j]);
else
dp[i][j]=dp[i-1][j];
// cout<<dp[i][j]<<' ';
}
// cout<<endl;
}
cout<<V-dp[n][V];
return 0;
}
/*
*/
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.