Clonetime limit:2000/1000ms (java/other) Memory limit:65536/65536k (Java/other) total submission (s): 8 Accepted Su Bmission (s): 5font:times New Roman | Verdana | Georgiafont Size:←→problem descriptionafter Eating food from Chernobyl, DRD got a super power:he could clone himself RI Ght now! He used this power for several times. He found out the this power is not as perfect as he wanted. For example, some of the cloned objects were tall, while some were short; Some of them were fat, and some were thin.
More evidence showed, which for both clones A and B, if a is no worse than B in all fields, then B could not survive. More specifically, DRD used a vector v to represent each of the his clones. The vector v has n dimensions, and representing a clone has n abilities. For the i-th dimension, V[i] is a integer between 0 and T[i], where 0 is the worst and t[i] are the best. For the Clones A and B, whose corresponding vectors were p and q, if for 1 <= i <= N, p[i] >= q[i], then B could Not survive.
Now, as DRD's friend, ATM wants to know what many clones can survive at the most. Inputthe first line contains an integer T, denoting the number of the the test cases.
For each test case:the first line contains 1 integer n, 1 <= n <= 2000. The second line contains N integers indicating t[1], t[2], ..., t[n]. It guarantees the sum of t[i] in each test case was no more than and 1 <= t[i]. Outputfor each test case, output an integer representing the answer MOD 10^9 + 7.Sample Input
21528 6
Sample Output
17
Source2014 ACM/ICPC Asia Regional Anshan Online test instructions: Given that each sheep has n properties, for A sheep B sheep, if all I (1<=i<=n) a[i]>=b[i] B sheep can survive, Ask how many sheep you can survive at the same time: All surviving sheep can be divided into attributes and the same situation dp[i][j] represents the number of schemes for which the sum of the previous I sheep attribute is J
You can see that sum = 0 and sum = Sum are the same number of schemes.
The same sum is symmetric, as is the number of combinations. So DP[N][SUM/2] is the biggest.
#include <iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<queue>#include<cmath>#include<map>using namespacestd; typedefLong Longll;#defineMoD 1000000007#defineINF 100000inline ll read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//******************************************************************intt,n,a[2005];intdp[2005][2005];intMain () {scanf ("%d",&T); while(t--) {scanf ("%d",&N); intsum=0; for(intI=1; i<=n;i++) {scanf ("%d",&A[i]); Sum+=A[i]; } memset (DP,0,sizeof(DP)); for(intI=0; i<=a[1];i++) {dp[1][i]=1; } for(intI=2; i<=n;i++) { for(intj=0; j<=sum;j++) { for(intk=0; k<=a[i]&&j+k<=sum;k++) {dp[i][j+k]= (dp[i][j+k]+dp[i-1][J])%MoD; } }} cout<<dp[n][sum/2]<<Endl; } return 0;}
Code
HDU ACM/ICPC Asia regional Anshan Online DP