BZOJ 3477: [Usaco2014 Mar]Sabotage( 二分答案 )

先二分答案m, 然后对于原序列 A[i] = A[i] - m, 然后O(n)找最大连续子序列和, 那么此时序列由 L + mx + R组成. L + mx + R = sum - n * m, sum为原序列的和.
假如二分的答案m是可行的, 那么 L + R = sum - n * m - mx 应该 <= 0
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
3477: [Usaco2014 Mar]Sabotage
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 106 Solved: 61
[Submit][Status][Discuss]
Description
Farmer John's arch-nemesis, Farmer Paul, has decided to sabotage Farmer John's milking equipment! The milking equipment consists of a row of N (3 <= N <= 100,000) milking machines, where the ith machine produces M_i units of milk (1 <= M_i <= 10,000). Farmer Paul plans to disconnect a contiguous block of these machines -- from the ith machine up to the jth machine (2 <= i <= j <= N-1); note that Farmer Paul does not want to disconnect either the first or the last machine, since this will make his plot too easy to discover. Farmer Paul's goal is to minimize the average milk production of the remaining machines. Farmer Paul plans to remove at least 1 cow, even if it would be better for him to avoid sabotage entirely. Fortunately, Farmer John has learned of Farmer Paul's evil plot, and he is wondering how bad his milk production will suffer if the plot succeeds. Please help Farmer John figure out the minimum average milk production of the remaining machines if Farmer Paul does succeed.
约翰的牧场里有 N 台机器,第 i 台机器的工作能力为 Ai。保罗阴谋破坏一些机器,使得约翰的
工作效率变低。保罗可以任意选取一段编号连续的机器,使它们停止工作。但这样的破坏只能搞一次,
而且保罗无法破坏第一台或最后一台机器。请问他该破坏哪些机器才能让剩下机器的工作效率的平均
数最小?为了显示存在感,保罗至少必须破坏一台机器。
Input
* Line 1: The integer N.
* Lines 2..1+N: Line i+1 contains M_i.
Output
* Line 1: The lowest possible average Farmer Paul can achieve, rounded to 3 digits after the decimal point, and printed with 3 digits after the decimal point.
Sample Input
5
1
7
8
2
Sample Output
OUTPUT DETAILS: The optimal solution is to remove the 7 and 8, leaving 5, 1, and 2, whose average is 8/3.
HINT
Source
BZOJ 3477: [Usaco2014 Mar]Sabotage( 二分答案 )的更多相关文章
- BZOJ_3477_[Usaco2014 Mar]Sabotage_二分答案
BZOJ_3477_[Usaco2014 Mar]Sabotage_二分答案 题意: 约翰的牧场里有 N 台机器,第 i 台机器的工作能力为 Ai.保罗阴谋破坏一些机器,使得约翰的工作效率变低.保罗可 ...
- 【bzoj】3477: [Usaco2014 Mar]Sabotage 01分数规划
这题算是01分数规划吧2333 sum-a[i]*x[i]=c*(n-x[i]) 化简一下就是sum-(a[i]-c)*x[i]-nc=0,每次找最大的(a[i]-c)*x[i](子段和),如果结果& ...
- [Usaco2014 Mar]Sabotage
[Usaco2014 Mar]Sabotage 题目 Farmer John"s arch-nemesis, Farmer Paul, has decided to sabotage Far ...
- [USACO14MAR] Sabotage 二分答案 分数规划
[USACO14MAR] Sabotage 二分答案 分数规划 最终答案的式子: \[ \frac{sum-sum[l,r]}{n-len[l,r]}\le ans \] 转换一下: \[ sum[1 ...
- [BZOJ 1816] [Cqoi2010] 扑克牌 【二分答案】
题目链接:BZOJ - 1816 题目分析 答案具有可以二分的性质,所以可以二分答案. 验证一个答案 x 是否可行,就累加一下各种牌相对于 x 还缺少的量,如果总和超过了 x 或 m ,就不可行. 因 ...
- [USACO14MAR]破坏Sabotage 二分答案
题目描述 Farmer John's arch-nemesis, Farmer Paul, has decided to sabotage Farmer John's milking equipmen ...
- [BZOJ 1816][Cqoi2010]扑克牌(二分答案)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1816 分析: 我先以为是道水题,但是要注意的是每套牌中Joker只能用1张的,所以就出现了可能 ...
- BZOJ 3479: [Usaco2014 Mar]Watering the Fields( MST )
MST...一开始没注意-1结果就WA了... ---------------------------------------------------------------------------- ...
- BZOJ 1044: [HAOI2008]木棍分割(二分答案 + dp)
第一问可以二分答案,然后贪心来判断. 第二问dp, dp[i][j] = sigma(dp[k][j - 1]) (1 <= k <i, sum[i] - sum[k] <= ans ...
随机推荐
- U盘安装Ubuntu14.4时遇到分区问题记录
1.在安装Ubuntu14.4时,遇到如果先分出 / 跟挂载的主分区时,后面只能再分一个swap,或者挂载一个/home,或者一个/ boot 时不能继续分区,当然想安装也是不能不能成功的. 解决办法 ...
- swiper,animate使用方法
1.先链接css和js文件 <link rel="stylesheet" type="text/css" href="css/swiper-3. ...
- Compare the value of entity field.
public class Program { static void Main(string[] args) { Program p = new Program(); p.Test(); Consol ...
- 引用类型List<T>的比较
一:重新Equals和GetHashCode方法 /// <summary> /// 描 述:弹出模型对象列表比较器(根据ID比较) /// </summary&g ...
- 【监控】使用probe对tomcat服务进行监控
1.运行环境(博主本地) JDK:jdk1.6 Tomcat:tomcat7 OS:Windows10 2.下载 点击下载 3.安装运行 1.解压,将probe文件夹复制放进tomcat里面的weba ...
- MVC中AuthorizeAttribute用法并实现权限控制
1.创建一个类(用来检查用户是否登录和用户权限)代码如下: public class AuthorizeFilterAttribute: AuthorizeAttribute { //Autho ...
- django 基础入门(一)
1. django 基本命令 新建project django-admin.py startproject project-name 新建app python manage.py startapp a ...
- poj 1726
http://poj.org/problem?id=1276 解题要点:用完全背包来模拟的解题,只不过加了限制条件used[]...其他的就一样了.. 注意: cash 和n 为0 的情况 #incl ...
- 深入浅出—JAVA(8)
8.接口与抽象类 不是抽象的类就被称为具体类 不同继承树的类也可以实现相同的接口,类可以实现多个接口.
- logback自定义格式转换器
创建自定义格式转换符有两步. 首先,必须继承ClassicConverter类.ClassicConverter对象负责从ILoggingEvent 提取信息,并产生一个字符串.例如,LoggerCo ...