很不错的一题,非常巧妙的用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. 在Eclipse中自定义类似syso的快捷代码模板

    sysout/syso syserr/ syse 点击菜单栏的“Window”->“Preferences”,打开“Preferences”对话框.在Preferences”对话框中点击“Jav ...

  2. 用with实现python的threading,新鲜啊

    哈哈,2.5以后可用.自动加锁释放,如同操作文件打开关闭一样. #!/usr/bin/env python # -*- coding: utf-8 -*- import threading impor ...

  3. RSA 加解密算法

    与DES不同,RSA算法中,每个通信主体都有两个钥匙,一个公钥一个私钥. 就是有2把钥匙1.使用publicKey可以对数据进行加密2.使用Key才能对数据进行解密单方向传输用公钥加密的数据,只有私钥 ...

  4. WebRTC之带宽控制部分学习(1) ------基本demo的介绍

    转自:http://blog.csdn.net/u013160228/article/details/46392037 WebRTC的代码真是非常之大啊,下载以及编译了我好几天才搞完..... 可以看 ...

  5. 智能车学习(十一)——陀螺仪学习

    一.学习说明 感觉就是配置I2C通信,然后直接移植51代码... 二.代码分享: 1.头文件: #ifndef I2C_GYRO_H_ #define I2C_GYRO_H_ /*********** ...

  6. 视觉差双排listview效果

    https://github.com/bavariama1/ListBuddies

  7. Servlet请求头response应用简单案例

    Servlet请求头response应用简单案例:访问AServlet重定向到BServlet,5秒后跳到CServlet,并显示图片: AServlet package cn.yzu; import ...

  8. LoadRunner如何监控Tomcat性能

    使用LoadRunner做性能测试,一般的直觉是LR只能完成脚本录制和编写模拟用户的请求行为,但是在某些情况下,要监控一些中间件或web服务器的性能时,就不能通过录制脚本来完成了,那么就需要手工来编写 ...

  9. POJ 1743 后缀数组

    题目链接:http://poj.org/problem?id=1743 题意:给定一个钢琴的音普序列[值的范围是(1~88)],现在要求找到一个子序列满足 1,长度至少为5 2,序列可以转调,即存在两 ...

  10. PHP 二分查找(详细)

    <?php //        PHP 二分查找 function search($arr, $sea){ $low = 0;                // 确定数组的开始的下标 $len ...