How many groups(DP)】的更多相关文章

题意: 定义:设M为数组a的子集(元素可以重复),将M中的元素排序,若排序后的相邻两元素相差不超过2,则M为a中的一个块,块的大小为块中的元素个数 给出长度为n的数组a,1<=n<=200,1<=ai<=200,可以任选最多两个数(可以不选),将它们值+1或-1.问如何修改可以使得数组中最大的块的大小最大. 思路: 想到是否可以DP:第一维是数组中的下标:由于最多能修改两次,要有一维记录当前状态的修改次数:为了能递推,还要一维记录当前状态的修改值是+1还是-1. 因此定义\(dp[…
OJ题目:click here~~ 题目分析:n个人分为若干组 , 每一个人描写叙述其所在的组前面的人数和后面的人数.求这n个描写叙述中,最多正确的个数. 设dp[ i ] 为前i个人的描写叙述中最多正确的个数,则dp[ n ] 为要求的.num[ i ][ j ]  保存说前面有i个人 , 后面有j个人的人数,显然num[ i ][ j ]不超过n - i - j; 转移方程dp[ i ] = max(dp[ i ] , dp[ j ]  + num[ j ][ n - i ])  ,详解见代…
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is the same written forwards and backwards. For example, ‘racecar’ is a palindrome, but ‘fastcar’ is not. A partition of a sequence of characters is a lis…
题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4293 Problem Description After the regional contest, all the ACMers are walking alone a very long avenue to the dining hall in groups. Groups can vary in size for kinds of reasons, which means, sev…
题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered wit…
C. Coloring Trees   ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right…
树状数组维护DP + 高精度 Description These days, Sempr is crazed on one problem named Crazy Thair. Given N (1 ≤ N ≤ 50000) numbers, which are no more than 109, Crazy Thair is a group of 5 numbers {i, j, k, l, m} satisfying: 1 ≤ i < j < k < l < m ≤ N Ai…
http://www.see-say.com/viewnews-47657.html http://cn.club.vmall.com/thread-970026-1-1.html http://www.jianshu.com/p/913943d25829 When adding support for multiple screens, applications do not work directly with resolution; applications should be conce…
传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They wal…
题目链接: D. Kindergarten time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated e…