首页 技术 正文
技术 2022年11月12日
0 收藏 314 点赞 4,694 浏览 1989 个字

所有的属性,以满足一定的条件,是,财产和等于sum/2结果最大.

Clone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 574    Accepted Submission(s): 277

Problem DescriptionAfter eating food from Chernobyl, DRD got a super power: he could clone himself right now! He used this power for several times. He found out that this power was 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 that for two clones A and B, if A was no worse than B in all fields, then B could not survive. More specifically, DRD used a vector v to represent each of his clones. The vector v has n dimensions, representing a clone having N abilities.
For the i-th dimension, v[i] is an integer between 0 and T[i], where 0 is the worst and T[i] is the best. For two 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 how many clones can survive at most. InputThe first line contains an integer T, denoting the number of 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 that the sum of T[i] in each test case is no more than 2000 and 1 <= T[i]. 
 OutputFor each test case, output an integer representing the answer MOD 10^9 + 7. Sample Input

2
1
5
2
8 6

 Sample Output

1
7

 Source

field=problem&key=2014+ACM%2FICPC+Asia+Regional+Anshan+Online&source=1&searchmode=source” style=”color:rgb(26,92,200); text-decoration:none”>2014 ACM/ICPC Asia Regional Anshan Online 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>using namespace std;typedef long long int LL;const LL mod=(1e9+7);int v[2020],n;
LL sum,dp[2][2000400];int main()
{
int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d",&n);
sum=0;
for(int i=0;i<n;i++)
{
scanf("%d",v+i);
sum+=v[i];
}
memset(dp,0,sizeof(dp));
for(int i=0;i<n;i++)
{
if(i==0)
{
for(int j=0;j<=v[i];j++) dp[0][j]=1;
continue;
}
for(int j=0;j<=sum/2;j++)
{
int temp=0;
for(int k=0;k<=v[i]&&k<=j;k++)
{
temp=(temp+dp[(i%2)^1][j-k])%mod;
}
dp[i%2][j]=temp;
}
}
printf("%d\n",dp[(n-1)%2][sum/2]);
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,982
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,499
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,343
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,126
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,760
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,796