Description
Farmer John went to cut some wood and left
Each cow
Write a program to determine the order in which FJ should pick up the cows so that the total number of flowers destroyed is minimized.
Input
Lines 2..
Output
Sample Input
6 3 1 2 5 2 3 3 2 4 1 1 6
Sample Output
86
Hint
每头牛对应需要赶回的时间和吃草速度,求吃最少的草。
一个贪心的题,按速度除以时间排序;证明:取两头牛,其他的牛吃的草就可以看成常量,若先赶a牛,吃的草是2*t[a]*d[b],若是b牛,就是2*t[b]*d[a],就是比较这两个的大小。这样看就是一个水题了。
#include
#include
using namespace std;
struct Cow{
}cow[100005];
bool cmp(const Cow &a, const Cow &b)
{
}
int main()
{
}
本文介绍了一个关于牛群运输调度的问题,通过贪心算法实现最优调度,以最小化花被破坏的数量。该算法首先对每头牛的破坏速度与其所需运输时间的比例进行排序,然后依次运输以达到最小化总损失的目标。
1176

被折叠的 条评论
为什么被折叠?



