B

时间: 2020-11-22|66次围观|0 条评论

 1 #include <bits/stdc++.h>


 2 
using 
namespace std;


 3 
const 
int maxn=
101;


 4 
const 
int maxnSum=
10005;


 5 
bool dp[maxn][maxnSum];


 6 
int A[maxn];


 7 


 8 


 9 
int main()


10 {


11     
int n,sum;


12     
while(scanf(
"
%d
",&n)!=EOF){


13         sum=
0;


14         
for(
int i=
1;i<=n*
2;i++){


15             scanf(
"
%d
",&A[i]);


16             sum+=A[i];


17         }


18         memset(dp,
0,
sizeof(dp));


19         dp[
0][
0]=
true;


20         
for(
int i=
1;i<=n*
2;i++){


21             
for(
int j=min(i,n);j>=
1;j--){


22                 
for(
int s=
1; s<=sum/
2;s++){


23                     
if(s>=A[i] && dp[j-
1][s-A[i]]){


24                         dp[j][s]=
true;


25                     }


26                 }


27             }


28         }


29         
for(
int s=sum/
2;s>=
1;--s){


30             
if(dp[n][s]){


31                 printf(
"
%d\n
",s);


32                 
break;


33             }


34         }


35     }


36     
return 
0;


37 }

转载于:https://www.cnblogs.com/acvc/p/4303961.html

原文链接:https://blog.csdn.net/weixin_30342827/article/details/99902556

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《B
   

还没有人抢沙发呢~