Protecting the Flowers 护花 bzoj-1634 Usaco-2007 Jan 题目大意:n头牛,每头牛有两个参数t和atk.表示弄走这头牛需要2*t秒,这头牛每秒会啃食atk朵花.求一个弄走牛的顺序,使得这些牛破坏最少的花. 注释:$1\le n \le 10^5$. 想法:贪心. 两头牛i和j. 只考虑这两头牛的位置. 如果i在j前面,拉走i的时候j会造成$2t_i*atk_j$朵花.反之同理. 比较两者谁大就放在前面. 在cmp中这样写就行了. 最后,附上丑陋的代码.…
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 448  Solved: 276[Submit][Status] Description Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, as usual. When he retur…
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 885  Solved: 575[Submit][Status][Discuss] Description Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, as usual. When…
http://www.lydsy.com/JudgeOnline/problem.php?id=1634 贪心.. 我们发现,两个相邻的牛(a和b)哪个先走对其它的牛无影响,但是可以通过 a的破坏花×b的时间 和 b的破坏花×a的时间 可以判断哪个先走. 那么可以应用到所有牛上.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iost…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1634 题意: 约翰留下他的N只奶牛上山采木.可是,当他回来的时候,他看到了一幕惨剧:牛们正躲在他的花园里,啃食着他心爱的美丽花朵! 为了使接下来花朵的损失最小,约翰赶紧采取行动,把牛们送回牛棚. 第i只牛所在的位置距离牛棚t[i](1 <= t[i] <= 2000000)分钟的路程,而在约翰开始送她回牛棚之前,她每分钟会啃食e[i](1 <= e[i] <= 100)朵鲜…
因为交换相邻两头牛对其他牛没有影响,所以可以通过交换相邻两头来使答案变小.按照a.t*b.f排降序,模拟着计算答案 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=100005; int n; long long ans,sum; struct qwe { int v,t; }a[N]; bool cmp(const qwe &a,c…
考虑相邻的两头奶牛 a , b , 我们发现它们顺序交换并不会影响到其他的 , 所以我们可以直接按照这个进行排序 --------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream>   #define rep( i ,…
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 493  Solved: 310[Submit][Status] Description Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, as usual. When he retur…
题目描述 Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cows were in his garden eating his beautiful flowers. Wanting to minimize the subsequent damage,…
Description Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cows were in his garden eating his beautiful flowers. Wanting to minimize the subsequent…