HDU 5000 Clone(离散数学+DP)(2014 ACM/ICPC Asia Regional Anshan Online)
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.
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].
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <functional>
using namespace std;
typedef long long LL; const int MAXN = ;
const int MOD = 1e9 + ; void update_add(int &a, int b) {
a += b;
if(a >= MOD) a -= MOD;
} int a[MAXN][MAXN], sum[MAXN][MAXN];
int b[MAXN];
int n, s, T; void solve() {
memset(a, , sizeof(a));
s = accumulate(b, b + n, ); for(int i = ; i <= b[]; ++i) a[][i] = ;
sum[][] = a[][];
for(int j = ; j <= s; ++j) sum[][j] = (sum[][j - ] + a[][j]) % MOD; for(int i = ; i < n; ++i) {
for(int j = ; j <= s; ++j) {
//for(int k = j - b[i]; k <= j; ++k) a[i][j] += a[i - 1][k];
if(j - b[i] <= ) a[i][j] = sum[i - ][j];
else a[i][j] = (sum[i - ][j] - sum[i - ][j - b[i] - ] + MOD) % MOD;
}
sum[i][] = a[i][];
for(int j = ; j <= s; ++j) sum[i][j] = (sum[i][j - ] + a[i][j]) % MOD;
}
} void print() {
for(int j = ; j <= s; ++j)
printf("%4d", j);
puts("");
for(int i = ; i < n; ++i) {
for(int j = ; j <= s; ++j)
printf("%4d", a[i][j]);
puts("");
}
} int main() {
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i = ; i < n; ++i) scanf("%d", &b[i]);
sort(b, b + n);
solve();
//print();
printf("%d\n", a[n - ][s / ]);
}
}
HDU 5000 Clone(离散数学+DP)(2014 ACM/ICPC Asia Regional Anshan Online)的更多相关文章
- HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP
Clone Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/65536K (Java/Other) Total Submiss ...
- HDU 5010 Get the Nut(2014 ACM/ICPC Asia Regional Xi'an Online)
思路:广搜, 因为空格加上动物最多只有32个那么对这32个进行编号,就能可以用一个数字来表示状态了,因为只有 ‘P’ 'S' 'M' '.' 那么就可以用4进制刚好可以用64位表示. 接下去每次就 ...
- HDU 5002 Tree(动态树LCT)(2014 ACM/ICPC Asia Regional Anshan Online)
Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node ...
- 2014 ACM/ICPC Asia Regional Anshan Online
默默的签到 Osu! http://acm.hdu.edu.cn/showproblem.php?pid=5003 #include<cstdio> #include<algorit ...
- hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi'an Online)
Mart Master II Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 4291 A Short problem(2012 ACM/ICPC Asia Regional Chengdu Online)
HDU 4291 A Short problem(2012 ACM/ICPC Asia Regional Chengdu Online) 题目链接http://acm.hdu.edu.cn/showp ...
- HDU 5029 Relief grain(离线+线段树+启发式合并)(2014 ACM/ICPC Asia Regional Guangzhou Online)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5029 Problem Description The soil is cracking up beca ...
- 2014 ACM/ICPC Asia Regional Xi'an Online(HDU 5007 ~ HDU 5017)
题目链接 A题:(字符串查找,水题) 题意 :输入字符串,如果字符串中包含“ Apple”, “iPhone”, “iPod”, “iPad” 就输出 “MAI MAI MAI!”,如果出现 “Son ...
- HDU 5052 Yaoge’s maximum profit 光秃秃的树链拆分 2014 ACM/ICPC Asia Regional Shanghai Online
意甲冠军: 特定n小点的树权. 以下n每一行给出了正确的一点点来表达一个销售点每只鸡价格的格 以下n-1行给出了树的侧 以下Q操作 Q行 u, v, val 从u走v,程中能够买一个鸡腿,然后到后面卖 ...
随机推荐
- [dpdk] 读官方文档(2)
续前节.切好继续: 一,文档里提到uio_pci_generic, igb_uio, vfio_pci三个内核模块,完全搞不懂,以及dpdk-devbind.py用来查看网卡状态,我得到了下边的输出: ...
- 抓包工具Charles 【转】
今天就来看一下Mac上如何进行抓包,之前有一篇文章介绍了使用Fidder进行抓包 http://blog.csdn.net/jiangwei0910410003/article/details/1 ...
- sql 语句查询练习题
1. 查询Student表中的所有记录的Sname.Ssex和Class列. select sname,ssex,class from student 2. 查询教师所有的单位即不重复的Depart列 ...
- IE 的resize事件问题
window的resize事件,真的让人无语! 我在动态设置元素的HTML内容后,窗口高度变化了,可是却不触发resize事件. 但是我在访问document.documentElement.scro ...
- 《黑客大曝光》实践部分——sql注入(7/8)
SQL注入实践 由于<黑客大曝光>中涉及到形形色色的攻击方式,从软件到硬件,甚至还有物理锁的开锁教程,当中的很多教程很有趣,但是我没有相关的环境,实践起来不好操作,比如说,查点扫描我还可以 ...
- nodejs express测试
1.页面请求 app.get('/list_user', function (req, res) { console.log("/list_user GET 请求"); //res ...
- 【Android开发学习笔记】【第四课】基础控件的学习
通过一个简单的例子来学习下面几种控件: 1.TextView:简单的文本显示控件 2.EditText:可以编辑的文本框 3.Button:按钮 4.Menu:这里指的是系统的Menu 5.Toast ...
- 利用快速排序原理找出数组中前n大的数
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #define MAX_SIZE 400001 ...
- IOS的APNS和PushKit门道详述
基本功 iOS在诞生之初为了最大程度的保证用户体验,做了一些高瞻远瞩且影响深远的设计.APNs(Apple Push Notification service)就是其中一项. 早期iOS设备的内存和C ...
- C/C++ 排序&&查找算法(面试)
一.排序 1.冒泡排序 void BubbleSort(int array[],int n) { ; ; ; ; ;i<n - ;i++) /*外循环控制排序的总趟数*/ { flag = ; ...