BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花( 贪心 )

考虑相邻的两头奶牛 a , b , 我们发现它们顺序交换并不会影响到其他的 , 所以我们可以直接按照这个进行排序
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
1634: [Usaco2007 Jan]Protecting the Flowers 护花
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 515 Solved: 329
[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 he returned, he found to his horror that the cows were in his garden eating his beautiful flowers. Wanting to minimize the subsequent damage, FJ decided to take immediate action and transport the cows back to their barn. Each cow i is at a location that is Ti minutes (1 <= Ti <= 2,000,000) away from the barn. Furthermore, while waiting for transport, she destroys Di (1 <= Di <= 100) flowers per minute. No matter how hard he tries,FJ can only transport one cow at a time back to the barn. Moving cow i to the barn requires 2*Ti minutes (Ti to get there and Ti to return). 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
* Line 1: A single integer
N * Lines 2..N+1: Each line contains two space-separated integers, Ti and Di, that describe a single cow's characteristics
第1行输入N,之后N行每行输入两个整数Ti和Di.
Output
* Line 1: A single integer that is the minimum number of destroyed flowers
一个整数,表示最小数量的花朵被吞食.
Sample Input
3 1
2 5
2 3
3 2
4 1
1 6
Sample Output
HINT
约翰用6,2,3,4,1,5的顺序来运送他的奶牛.
Source
BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花( 贪心 )的更多相关文章
- BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花
Description Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the g ...
- BZOJ 1634 [Usaco2007 Jan]Protecting the Flowers 护花:贪心【局部分析法】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1634 题意: 约翰留下他的N只奶牛上山采木.可是,当他回来的时候,他看到了一幕惨剧:牛们正 ...
- bzoj 1634: [Usaco2007 Jan]Protecting the Flowers 护花【贪心】
因为交换相邻两头牛对其他牛没有影响,所以可以通过交换相邻两头来使答案变小.按照a.t*b.f排降序,模拟着计算答案 #include<iostream> #include<cstdi ...
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 493 So ...
- [BZOJ1634][Usaco2007 Jan]Protecting the Flowers 护花 贪心
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 885 So ...
- 【BZOJ】1634: [Usaco2007 Jan]Protecting the Flowers 护花(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1634 贪心.. 我们发现,两个相邻的牛(a和b)哪个先走对其它的牛无影响,但是可以通过 a的破坏花× ...
- 【bzoj1634】[Usaco2007 Jan]Protecting the Flowers 护花 贪心
题目描述 Farmer John went to cut some wood and left N (2 <= N <= 100,000) cows eating the grass, a ...
- BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 448 So ...
- [bzoj1634][Usaco2007 Jan]Protecting the Flowers 护花_贪心
Protecting the Flowers 护花 bzoj-1634 Usaco-2007 Jan 题目大意:n头牛,每头牛有两个参数t和atk.表示弄走这头牛需要2*t秒,这头牛每秒会啃食atk朵 ...
随机推荐
- linux下查找文件、排序、查看文件内容
本文介绍下,在linux系统中,查找文件的命令用法,以及按时间排序找到的目标文件的方法. 1.例如:查找当前目录下所有.ini文件,并按时间排序 示例: find ./ -name *.ini ...
- SQL Server 数据库所有者
1. 数据库所有者应当永远是 sa 用户 2. 改变数据库的所有者 alter authorization on database :: databaseName to sa; -- 这一句话把数据库 ...
- PCB板上镀镍厚度
PCB制造工业由于成本.周期时间和材料兼容性的原因,对减少沉淀在电路板上的镍的数量感兴趣.最小镍的规格应该帮助防止铜对金表面的扩散.保持良好的焊接点强度.和较低的接触电阻.最大镍的规格应该允许板制造的 ...
- 苹果iPhone不能判断红外发射管的好坏
用手机来检测红外发射管好坏是目前比较常用的方法.实际操作比较简单,就是按照红外发射管的工作电压给发射管接上电源后,把手机的摄像头对着红外发射管就能看出好坏了.由于红外线是肉眼看不见的,如果不通过手机摄 ...
- PROS Step:只需几分钟即可创建优化的价目表,并发现即时收益机会。
多年来,各个公司一直使用手动流程和电子表格来制定产品和服务定价,而没有真正意义上的方法或策略.在我写这篇文章时仍然如此! 但是,如今的形势已经改变.利用 PROS Step,公司可以将其数据上传到 M ...
- POJ 1721 CARDS(置换群)
[题目链接] http://poj.org/problem?id=1721 [题目大意] 给出a[i]=a[a[i]]变换s次后的序列,求原序列 [题解] 置换存在循环节,因此我们先求出循环节长度,置 ...
- mongoose的用法(注:连接数据库)
第一步:连接数据库: mongoose.connect('mongodb://'+user+':'+pass+'@mongo.duapp.com:'+port+'/xzWIRHYlWLAApdsfAz ...
- Nothing2
重压下似乎找不到释放的出口. 拳套早已封存, 竹箫也非常久不去碰它, 如今预计已然吹不出心弦之曲, 围棋的造诣也退步到家了. 是不是仅仅有当思路电光石火, 当指尖快如闪电, 当键盘上舞动的手指跟上思想 ...
- BingMap的GeocodeService进行地理位置正向和反向检索--后台实现
一.加入GeocodeService的Web服务引用 地理编码服务(GeocodeService)是以WCF技术公布的一个Web服务,地图编码服务提供了以一个有效的物理地址在地图上匹配其相应的地图地址 ...
- SQL Server 2012学习笔记 1 命令行安装
setup.exe /Q /IACCEPTSQLSERVERLICENSETERMS /ACTION=install /PID=748RB-X4T6B-MRM7V-RTVFF-CHC8H /FEATU ...