TC SRM 591 DIV2 1000
很不错的一题,非常巧妙的用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的更多相关文章
- TC SRM 593 DIV2 1000
很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...
- Topcoder Srm 673 Div2 1000 BearPermutations2
\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...
- Topcoder Srm 671 Div2 1000 BearDestroysDiv2
\(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...
- TC SRM 663 div2 B AABB 逆推
AABB Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description One day, Jamie noticed that many En ...
- SRM 595 DIV2 1000
数位DP的感觉,但是跟模版不是一个套路的,看的题解,代码好理解,但是确实难想. #include <cstdio> #include <cstring> #include &l ...
- TC SRM 663 div2 A ChessFloor 暴力
ChessFloor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description Samantha is renovating a squa ...
- TC SRM 665 DIV2 A LuckyXor 暴力
LuckyXorTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description A lucky number is a positive int ...
- SRM 146 DIV2 1000
Problem Statement A well-known riddle goes like this: Four people are crossing an old bridge. T ...
- TC SRM 591
表示第一次在div1,我要记录一下... 木有挂0,第一题不怎么难的,读题读了20分钟,又想了20分钟,时间有点长,然后各种小心,然后得了140分.... 后两个题,根本木有看,貌似做出来的也不多.. ...
随机推荐
- 全局压缩http响应头
见代码: public class CompressAttribute : ActionFilterAttribute { public override void OnActionExecuting ...
- 【翻译十三】java-并发之饥饿与活锁
Starvation and Livelock Starvation and livelock are much less common a problem than deadlock, but ar ...
- 攻城狮在路上(壹) Hibernate(五)--- 映射一对多关联关系
关联是有方向的,包含单向关联和双向关联.分别讨论.本文以客户Customer和订单Order来进行讨论:一个Customer有多个Order,每个Order对应一个Customer. Customer ...
- 重新开始刷dp,哈哈哈
转载于: http://blog.csdn.net/cc_again?viewmode=list ---------- Accagain 2015年1月29日 从头开始
- hibernate 关联映射
关联关系大致分为两大类: 1.单向关系:只需单向访问关联端.例如:只能通过老师访问学生,或者只能通过学生访问老师. 2.双向关系:关联的两端可以互相访问.例如:老师和学生之间可以互相访问. 单向关联可 ...
- Java Thread join() 的用法
Java Thread中, join() 方法主要是让调用改方法的thread完成run方法里面的东西后, 在执行join()方法后面的代码.示例: class ThreadTesterA imple ...
- 利用opencv进行相机标定程序
#include "Stafx.h" ; //棋盘上有13个格子,那么角点的数目12 ; ; //图片的总张数 int main(int argc, char** argv) { ...
- 获取内核当前执行模块和当前发生异常地址和线程异常Handler调用步骤
循环每个内核模块 统计模块大小 判断触发异常的地址属于那个模块.来确定模块 获取发生异常地址 nt!_EXCEPTION_RECORD +0x000 ExceptionCode : -21391605 ...
- WebSocket协议开发
一直以来,网络在很大程度上都是围绕着HTTP的请求/响应模式而构建的.客户端加载一个网页,然后直到用户点击下一页之前,什么都不会发生.在2005年左右,Ajax开始让网络变得更加动态了.但所有的HTT ...
- js:方法2. 字符串
String.charAt()/String.charCodeAt() string.charAt(n); n:The index of the character that should be re ...