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分.... 后两个题,根本木有看,貌似做出来的也不多.. ...
随机推荐
- Mongo DB Study: first face with mongo DB
Mongo DB Study: first face with mongo DB 1. study methods: 1. Translate: I am the mongo DB organiz ...
- Power BI for Office 365介绍
微软在七月份发布了一个新产品,它建立在微软的云的第一个数据平台- Power BI for Office 365.Satya Nadella,服务器和工具业务总裁,在当天的上午在微软的年度全球合作伙伴 ...
- select * from salgrade for update和select * from salgrade for update nowait区别
1,select * from salgrade for update session1 session2 SQL> delete salgrade where grade=1; 1 row d ...
- IOS 100 - level2 Boss
创建第一个app, buid, run. 过程 1 首先是按照知乎上的推荐去看了传说中的公开课了.看到第二集的时候觉得有种回到大学听老师上课的感觉--昏昏欲睡. 代码是一门实践课程,我觉得自己实现点东 ...
- 快速熟悉python 下使用mysql(MySQLdb)
首先你需要安装上mysql和MySQLdb模块(当然还有其他模块可以用),这里我就略过了,如果遇到问题自行百度(或者评论在下面我可以帮忙看看) 这里简单记录一下自己使用的学习过程: 一.连接数据库 M ...
- GitHub 使用教程图文详解(转)
大纲: 一.前言 二.GitHub简介 三.注册GitHub账号 四.配置GitHub 五.使用GitHub 六.参与GitHub中其它开源项目 七.总结 注,GitHub官网:https://git ...
- Codeforces Round #370 (Div. 2) D. Memory and Scores DP
D. Memory and Scores Memory and his friend Lexa are competing to get higher score in one popular c ...
- unable to access android sdk add-on list
在bin\properties里添加disable.android.first.run=true
- input实时监控和获取焦点的问题,oninput,ononfocus
1.input监控实时输入问题,google浏览器使用oninput,其他浏览器(IE6/7/8)使用onpropertychange var ie = !!window.ActiveXObject; ...
- user_jj两条记录改成一条
1.前台index控制器,用user_jj.*add找到,home_ddxx_pcz_cl() 2.前台index控制器,用user_jj.*add找到,tgbz_list_sd_cl(),tgbz_ ...