Cow Acrobats(贪心)】的更多相关文章

POJ 3045 Cow Acrobats 这是个贪心的题目,和网上的很多题解略有不同,我的贪心是从最下层开始,每次找到能使该层的牛的风险最小的方案, 记录风险值,上移一层,继续贪心. 最后从遍历每一层的风险值,找到其中的最大值 我一开始对sum-p[i].a-p[i].b从小到大排序,这样第一次取出的就是能使最下层的牛的风险最小的方案,在上移一层时,这一层的风险值   为sum-p[i].a-p[i].b-p[0].a,由于p[0].a是固定值,所以第二次直接取出的就是能使该层的牛的风险最小的…
Cow Acrobats Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3686   Accepted: 1428 Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tig…
题目:http://poj.org/problem?id=3045 题意:每个牛都有一个wi和si,试将他们排序,每头牛的风险值等于前面所有牛的wj(j<i)之和-si,求风险值最大的牛的最小风险值 分析:这就是noip2012 T2的来源= =只不过这里是加,noip里是乘 不妨设所有牛都按最优顺序排好了,考虑相邻的两头牛i和i+1,如果交换他们的位置,那么对前面和后面的结果都无影响,只是他们两个的风险值变化了(变大了),于是我们可以得到这个时候i和i+1的关系 设w1+w2+...+wi-1…
题目: poj3045 Cow Acrobats 解析: 贪心题,类似于国王游戏 考虑两个相邻的牛\(i\),\(j\) 设他们上面的牛的重量一共为\(sum\) 把\(i\)放在上面,危险值分别为\(x_1=sum-s_i\),$ x_2=sum+w_i-s_j$ 把\(j\)放在上面,危险值分别为\(x_3=sum-s_j\), \(x_4=sum+w_j-s_i\) 若把j放在上面更优,则有\(max(x_3,x_4)<max(x_1,x_2)\) 有四种情况 \(x_3<x_1\) \…
Cow Acrobats Descriptions 农夫的N只牛(1<=n<=50,000)决定练习特技表演. 特技表演如下:站在对方的头顶上,形成一个垂直的高度. 每头牛都有重量(1 <= W_i <= 10,000)和力量(1 <= S_i <= 1,000,000,000).奶牛崩溃的风险等同于她身上所有的奶牛的重量(当然不包括她自己)减去她的力量.你的任务是确定奶牛的顺序,从而使得所有牛的风险中最大的一个尽量小.Input第1行:一个整数N 第2 . .N+ 1…
Cow Acrobats Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4998   Accepted: 1892 Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tig…
1629: [Usaco2007 Demo]Cow Acrobats Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 601  Solved: 305[Submit][Status] Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet pre…
题目链接:http://poj.org/problem?id=3045 Cow Acrobats Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5713   Accepted: 2151 Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. The…
Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tightrope walking and swinging from the trapeze (and their last attempt at firing a cow out of a ca…
BUPT2017 wintertraining(16) #4 B POJ - 3045 题意 n(1 <= N <= 50,000) 个牛,重wi (1 <= W_i <= 10,000),力气si (1 <= S_i <= 1,000,000,000),堆成一个竖线,risk值为每只牛上面的w之和-它的si,使它的最大值最小,输出最小值. 题解 根据数据范围也可以知道要贪心. wi和si之和小的放上面.不要漏掉最top的牛的risk值. 证明:设i,j是相邻的两只牛,…