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朵 ...
随机推荐
- 派生类地址比基类地址少4(子类与基类指针强行转换的时候,值居然会发生变化,不知道Delphi BCB是不是也这样) good
大家对虚表并不陌生,都知道每个含有虚函数的类对象都有1个虚指针,但是在现实使用中,却总是因为这而调试半天,才发现原来是虚指针惹的祸.我这几天在调试代码时候也中招了,我的问题是这样的,如下图,CTree ...
- 贪吃蛇AI
贪吃蛇AI 作者:CodeNoob 转载请标明作者和出处 序言 前几天在网上看到一张让人涨姿势的图片,这张图片我很早以前看过,当时就觉得肯定是程序实现的,只是当时还比较渣,不会算法.这次学了java也 ...
- cluster maintain manager Software群集管理软件
1,ocfs2 2,crmsh(cluster management shell,)==crm shell [pacemaker OpenAIS,heartbeat,corosync,crmsh] 3 ...
- 动态调用python类和函数
类 class test1(object): def __init__(self): print "i am test1" class test2(object): def __i ...
- 浅析JQuery中的html(),text(),val()区别
1.HTML html():取得第一个匹配元素的html内容.这个函数不能用于XML文档.但可以用于XHTML文档 html(val):设置每一个匹配元素的html内容.这个函数不能用于XML文档.但 ...
- 使用coding.net来托管源码(可以免费存放私有项目的哦)(转载)
coding.net是国内新兴的一个项目管理平台,功能主要包括:代码托管.在线运行环境.监控代码质量,兼有一定的社交功能.在线运行环境支持Java.Ruby.Node.js.PHP.Python.Go ...
- NGUI Button 3中点击事件的触发
NGUI事件的种类很多,比如点击.双击.拖动.滑动等等,他们处理事件的原理几乎万全一样,本文只用按钮来举例. 1.直接监听事件 把下面脚本直接绑定在按钮上,点击按钮触发的方法名必须为OnClick,当 ...
- error 和 exception 有什么区别?
1.error指恢复不是不可能但非常困难的情况下的一种严重错误.比如内存溢出,不指望程序可以处理这样的情况. 2.exception表示一种设计或者实现问题,如果程序正常运行,则从不会发生.
- Java 网络编程(三) 创建和使用URL访问网络上的资源
链接地址:http://www.cnblogs.com/mengdd/archive/2013/03/09/2951877.html 创建和使用URL访问网络上的资源 URL(Uniform Reso ...
- 指定字符串加密(对称加密DES)
/* * @(#) EncrypAES.java */ import java.security.InvalidKeyException; import java.security.NoSuchAlg ...