标签:efi name memset min max bsp 题目 sample exp
24
6
8
3
12
7
9
7
0
题解:背包问题
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <cstdlib> 7 #include <iomanip> 8 #include <cmath> 9 #include <ctime> 10 #include <map> 11 #include <set> 12 #include <queue> 13 using namespace std; 14 #define lowbit(x) (x&(-x)) 15 #define max(x,y) (x>y?x:y) 16 #define min(x,y) (x<y?x:y) 17 #define MAX 100000000000000000 18 #define MOD 1000000007 19 #define pi acos(-1.0) 20 #define ei exp(1) 21 #define PI 3.141592653589793238462 22 #define INF 0x3f3f3f3f3f 23 #define mem(a) (memset(a,0,sizeof(a))) 24 typedef long long ll; 25 ll gcd(ll a,ll b){ 26 return b?gcd(b,a%b):a; 27 } 28 bool cmp(int x,int y) 29 { 30 return x>y; 31 } 32 const int N=10005; 33 const int mod=1e9+7; 34 int a[31]; 35 int main() 36 { 37 std::ios::sync_with_stdio(false); 38 int v,n,s,i; 39 cin>>v>>n; 40 int dp[v+1]; 41 memset(dp,0,sizeof(dp)); 42 for(i=0;i<n;i++){ 43 cin>>a[i]; 44 for(int j=v;j>=a[i];j--){ 45 dp[j]=max(dp[j],dp[j-a[i]]+a[i]); 46 } 47 } 48 cout<<v-dp[v]; 49 return 0; 50 }
标签:efi name memset min max bsp 题目 sample exp
原文地址:http://www.cnblogs.com/shixinzei/p/7281625.html