很不错的一题,非常巧妙的用DP顺序解决这个问题。。。

可以发现,只和A里面最小的有关系。。。

 #include <cstdio>
#include <cstring>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define LL long long
int dp[*+];
vector<int>::iterator it;
bool cmp(int a,int b)
{
return a > b;
}
class YetAnotherTwoTeamsProblem
{
public :
LL count(vector <int> skill)
{
int p[],n,sum,i,j;
LL ans = ;
n = skill.size();
sum = ;
for(i = ,it = skill.begin();i < n;i ++,it ++)
{
p[i] = *it;
sum += p[i];
}
sort(p,p+n,cmp);
if(p[] > sum - p[])
ans ++;
dp[] = ;
for(i = ;i < n-;i ++)
{
for(j = sum;j >= p[i];j --)
{
dp[j] += dp[j-p[i]];
}
for(j = ;j <= sum;j ++)
{
if(p[i+] + j > sum - p[i+] - j&&j < sum-j)
ans += dp[j];
if(j >= sum - j)
break;
}
}
return ans;
}
};

TC SRM 591 DIV2 1000的更多相关文章

  1. TC SRM 593 DIV2 1000

    很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...

  2. Topcoder Srm 673 Div2 1000 BearPermutations2

    \(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...

  3. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  4. TC SRM 663 div2 B AABB 逆推

    AABB Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description One day, Jamie noticed that many En ...

  5. SRM 595 DIV2 1000

    数位DP的感觉,但是跟模版不是一个套路的,看的题解,代码好理解,但是确实难想. #include <cstdio> #include <cstring> #include &l ...

  6. TC SRM 663 div2 A ChessFloor 暴力

    ChessFloor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description Samantha is renovating a squa ...

  7. TC SRM 665 DIV2 A LuckyXor 暴力

    LuckyXorTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description A lucky number is a positive int ...

  8. SRM 146 DIV2 1000

    Problem Statement      A well-known riddle goes like this: Four people are crossing an old bridge. T ...

  9. TC SRM 591

    表示第一次在div1,我要记录一下... 木有挂0,第一题不怎么难的,读题读了20分钟,又想了20分钟,时间有点长,然后各种小心,然后得了140分.... 后两个题,根本木有看,貌似做出来的也不多.. ...

随机推荐

  1. poj 1182:食物链(种类并查集,食物链问题)

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44168   Accepted: 12878 Description ...

  2. OpenCV-paper detection & perspective transformation 相关资料

    经过一段时间的搜索,决定把搜过的资料都汇集在此,以免重复劳动,几乎来自stackoverflow OpenCV C++/Obj-C: Detecting a sheet of paper / Squa ...

  3. [v9] 列表页 调用 正文内容 或 自定义 字段(moreinfo的调用方法)

    "才能使用的字段) id content readpoint groupids_view paginationtype maxcharperpage template paytype all ...

  4. hdu 5294 最短路+最大流 ***

    处理处最短路径图,这个比较巧妙 链接:点我

  5. hdu 3032 sg打表找规律 *

    有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 打表代码: #include ...

  6. C专家编程cdecl

    理解所有分析过程的代码段 Page71(中文版) 你可以轻松地编写一个能够分析C语言的声明并把他们翻译成通俗语言的程序.事实上,为什么不?C语言声明的基本形式已经描述清楚.我们所需要的只是编写一段能够 ...

  7. loj 1271

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26981 思路:题目的意思是求给定的起点到终点的最短路径序列,并且这 ...

  8. Spring官网改版后下载

    Spring官网改版后找了好久都没有找到直接下载Jar包的链接,下面汇总些网上提供的方法,亲测可用. 1.直接输入地址,改相应版本即可:http://repo.springsource.org/lib ...

  9. 【转】Kylin的Hierarchies,Derived维度方面配置优化

    http://blog.csdn.net/jiangshouzhuang/article/details/51286150 Hierarchies: 理论上对于N维度,我们可以进行2的N次方的维度组合 ...

  10. HDU 2222 Keywords Search (AC自动机)

    题意:给你一些模式串,再给你一串匹配串,问你在匹配串中出现了多少种模式串,模式串可以相同 AC自动机:trie树上进行KMP.首先模式串建立trie树,再求得失配指针(类似next数组),其作用就是在 ...