很不错的一题,非常巧妙的用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. AJax中post与get请求注意事项

    在使用ajax提交表单时,一定要区分提交按钮的形式和数据表头的设置,实例如下: GET请求: HTML代码: <!doctype html> <html lang="en& ...

  2. [LeetCode] Same Tree

    Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...

  3. 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)

    Gym Class  Accepts: 849  Submissions: 4247  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65 ...

  4. 用脚本创建和恢复 DB2数据库

    CREATE DATABASE AUTOMATIC STORAGE YES ON 'C:\' DBPATH ON 'C:\' USING CODESET GBK TERRITORY CN COLLAT ...

  5. Oracle 【IT实验室】数据库备份与恢复之:如何对Oracle数据库文件进行恢复与备份

    任何数据库在长期使用过程中,都会存在一定的安全隐患.对于数据库管理员来说不能仅寄希望于计算机操作系统的安全运行,而是要建立一整套的数据库备份与恢复机制.当数据库发生故障后,希望能重新建立一个完整的数据 ...

  6. PHPCMS_v9 wap不同列表采用不同模板的方法

    .在phpcms\modules\wap\index.php中搜索 $template = ($TYPE[$typeid]['parentid']==0 && in_array($ty ...

  7. 解决Android解析图片的OOM问题!!!(转)

    大家好,今天给大家分享的是解决解析图片的出现oom的问题,我们可以用BitmapFactory这里的各种Decode方法,如果图片很小的话,不会出现oom,但是当图片很大的时候 就要用BitmapFa ...

  8. IMAGE_LOAD_CONFIG_DIRECTORY64 SafeSEH检测 表

    IMAGE_LOAD_CONFIG_DIRECTORY64 typedef struct { DWORD Size; DWORD TimeDateStamp; WORD MajorVersion; W ...

  9. Jmeter之csv、用户自定义变量以及Query Type分析(八)

    很多童鞋不知道对于Jmeter的Query Type 不知道选哪个,为什么选,怎么选! 下面这边做个简单的分析, 那么首先什么是CSV Data Set Config,有什么用呢? CSV Data ...

  10. cf #365b 巧妙的统计

     Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input standard inp ...