bzoj3477[Usaco2014 Mar]Sabotage】的更多相关文章

科学二分姿势 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…
题意 给出一个长为n的正整数序列(n<=1e5),要求选出一个非空前缀和一个非空后缀(这两段不能够加起来组成整个序列),使得这个前缀和后缀中的所有数字一起求平均数的结果最小 分析 最大/最小化平均数的题目一眼就是二分这个平均数,原序列每个数字减去平均数,转化为和大于0/和小于0的判断.求求前缀和没了. 咸鱼选手这都1A不了QAQ #include<cstdio> const int maxn=100005; int a[maxn]; double sum[maxn]; double mi…
先二分答案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 ------------------------------------------------------------------------------------- #inc…
[Usaco2014 Mar]Sabotage 题目 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…
这题算是01分数规划吧2333 sum-a[i]*x[i]=c*(n-x[i]) 化简一下就是sum-(a[i]-c)*x[i]-nc=0,每次找最大的(a[i]-c)*x[i](子段和),如果结果<=0就是存在方案使sum-a[i]*x[i]=c*(n-x[i]). 注意要至少选一个…… #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define max…
3479: [Usaco2014 Mar]Watering the Fields Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 81  Solved: 42[Submit][Status] Description Due to a lack of rain, Farmer John wants to build an irrigation system to send water between his N fields (1 <= N <=…
MST...一开始没注意-1结果就WA了... ---------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<iostream>   #define r…
BZOJ_3477_[Usaco2014 Mar]Sabotage_二分答案 题意: 约翰的牧场里有 N 台机器,第 i 台机器的工作能力为 Ai.保罗阴谋破坏一些机器,使得约翰的工作效率变低.保罗可以任意选取一段编号连续的机器,使它们停止工作.但这样的破次,而且保罗无法破坏第一台或最后一台机器.请问他该破坏哪些机器才能让剩下机器的工作效率的平均数最小?为了显示存在感,保罗至少必须破坏一台机器. 分析: 二分出答案k,将a[i]-k,求出2到n-1最大子段和mx.用sum-mx既是剩下的前一段后…
3479: [Usaco2014 Mar]Watering the Fields Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 174  Solved: 97[Submit][Status][Discuss] Description Due to a lack of rain, Farmer John wants to build an irrigation system to send water between his N fields (1…
BZOJ_3476_[Usaco2014 Mar]The Lazy Cow_扫描线+切比雪夫距离 Description It's a hot summer day, and Bessie the cow is feeling quite lazy. She wants to locate herself at a position in her field so that she can reach as much delicious grass as possible within only…