HDU-2576 Tug of War】的更多相关文章

Tug of War Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8187   Accepted: 2204 Description A tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must b…
还是神奇的随机算法,,(看视频说这是爬山法??) 其实就是把序列随机分成两半(我太弱,只知道random_shuffle),然后再每个序列里rand一个位置,x,y然后比较是不是交换之后是更优的. 然后重复这个过程. 神奇.. #include<cstdio> #include<cstring> #include<ctime> #include<iostream> #include<algorithm> #define LL long long…
http://poj.org/problem?id=2576 二维数组01背包的变形. Tug of War Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8147   Accepted: 2191 Description A tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must b…
Description Problem F: Tug of War A tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one team or the other; the number of people on the two teams must n…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2809 题目大意:给出战神吕布的初始攻击力ATI.防御力DEF.生命值HP.每升一级增加的攻击力In_ATI,增加的防御力In_DEF和增加的生命值In_HP.然后给出n个敌人的攻击力.防御力.生命值和杀死该单位能获得的经验值EXP. 吕布的初始经验值EXP是0,初始等级level是1,每当EXP>=level*100时就会升级. 在吕布LvBu和敌人A之间的战斗有3条规则 1.吕布攻击A,A失去 M…
God of War Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1671    Accepted Submission(s): 647   Problem Description At 184~280 A.D ,there were many kingdoms in China. Three strongest among them…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=973 #include <cstdio> #include <cstring> #include <algorithm> #define ll long long using namespace std; ]; int n; ll dp[]; int mai…
状压DP.我认为是数据水了,用打死了哪几只作为状态,AC代码只需要保存当前状态的最大血量,完全没有考虑攻击力大小. 个人认为正确DP应该这样的:dp[状态][等级],但这样写不能AC,时间复杂度会很大,但答案应该是正确的. #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<algorithm> #include<iostream>…
建立二分图,首先如果存在度数为$0$的点,那么显然无解. 如果存在度数为$1$的点,那么这个点的匹配方案固定,可以通过拓扑排序去掉所有这种点. 那么现在剩下的点度数都至少为$2$,因为左右点数相等,且左边每个点度数都是$2$,所以右边只能是每个点的度数都是$2$. 在这种情况下每个连通块是一个环,相邻两条边不能同时选,一共有两种情况$x$和$y$. 假设$x\leq y$,那么把$x$加入$sum$,$y-x$既可以加入,又可以不加入,对$y-x$进行01背包即可. 注意到本题中物品数不超过$2…
题目:有n个人分成两组,两组人数差不能超过1,找到两组的人重量之差的最小值. 分析:dp,二维01背包. 由于必须放在两个组中的一组,直接背包全部可到状态, 取出相差不超过 1的最接近 sum/2的值就可以. 说明:430ms. .好慢啊.. (2011-9-30 18:37). #include <stdio.h> #include <stdlib.h> #include <string.h> int f[ 52 ][ 22501 ]; int h[ 101 ]; i…