标签:scan panel ota show space mis http 一个 ext
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=5616
题目:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1810 Accepted Submission(s): 754
Input
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 int main(){ 6 int t,n,m; 7 int weight[205]; 8 int dp[20005]; 9 int sum; 10 scanf("%d",&t); 11 while (t--) { 12 scanf("%d",&n); 13 memset(dp, 0, sizeof(dp)); 14 dp[0]=1; 15 sum=0; 16 for (int i=0; i<n; i++) { 17 scanf("%d",&weight[i]); 18 sum+=weight[i]; 19 } 20 sort(weight, weight+n); 21 for (int i=0; i<n; i++) { 22 for (int j=sum; j>=0; j--) { 23 if(j>=weight[i])dp[j]=max(dp[j], dp[j-weight[i]]); 24 else dp[j]=max(dp[j], dp[weight[i]-j]); 25 } 26 } 27 scanf("%d",&m); 28 for (int i=0; i<m; i++) { 29 int w; 30 scanf("%d",&w); 31 printf("%s\n",dp[w]?"YES":"NO"); 32 } 33 } 34 return 0; 35 }
标签:scan panel ota show space mis http 一个 ext
原文地址:http://www.cnblogs.com/uniles/p/7182243.html