【二分贪心】Bzoj3969 [WF2013] Low Power
Description
Input
Output
Sample Input
1 2 3 4 5 6 7 8 9 10 11 12
Sample Output
HINT
根据经验肯定先要排序
最大值最小熟悉的设问那么考虑要二分
肯定要尽量往前选
于是检验
//检验部分借鉴了别人的代码真是精简
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e6+; int n,k,a[maxn]; int check(int x){
for(int p=,q=;q<n&&p<=*n*k;p++){
if(p->q**k) return ;
if(a[p+]-a[p]<=x) q++,p++;
}
return ;
} int main(){
scanf("%d%d",&n,&k);
for(int i=;i<=*n*k;i++)
scanf("%d",&a[i]);
sort(a+,a+*n*k+); int l=,r=a[*n*k]-a[];
while(l<r){
int mid=(l+r)>>;
if(check(mid))
r=mid;
else
l=mid+;
} printf("%d",l);
return ;
}
【二分贪心】Bzoj3969 [WF2013] Low Power的更多相关文章
- bzoj3969 [WF2013]Low Power
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3969 [题解] 二分答案x,贪心选取,如果选取了i个,有j对,那么要满足i<=2*j* ...
- bzoj 3969: [WF2013]Low Power 二分
3969: [WF2013]Low Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...
- BZOJ_3969_[WF2013]Low Power_二分答案
BZOJ_3969_[WF2013]Low Power_二分答案 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能 ...
- tensorfolw配置过程中遇到的一些问题及其解决过程的记录(配置SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real-Time Object Detection for Autonomous Driving)
今天看到一篇关于检测的论文<SqueezeDet: Unified, Small, Low Power Fully Convolutional Neural Networks for Real- ...
- Low Power Consumption Design --- MCU Attention
20161008 note : I have a PCB board called 'A' where a piece of STM8L052C6 and a piece of CC1101 are ...
- Codeforces Gym 100231B Intervals 线段树+二分+贪心
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要 ...
- Low Power之CPF/UPF
1 CPF The Common Power Format is a standard promoted by the Low Power Coalition at Si2. CPF is also ...
- 2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 二分+贪心
/** 题目:2016-2017 ACM-ICPC CHINA-Final Ice Cream Tower 链接:http://codeforces.com/gym/101194 题意:给n个木块,堆 ...
- 【bzoj2097】[Usaco2010 Dec]Exercise 奶牛健美操 二分+贪心
题目描述 Farmer John为了保持奶牛们的健康,让可怜的奶牛们不停在牧场之间 的小路上奔跑.这些奶牛的路径集合可以被表示成一个点集和一些连接 两个顶点的双向路,使得每对点之间恰好有一条简单路径. ...
随机推荐
- jasper(二):制作饼状图和柱状图
在新建一个框架之后 我们也是要执行 add dataset,来添加一个链接数据库的语句,因为这是个饼状图,所以要用group by 全部放入右边的框架 点完成 接下来,就是要创建饼状图,就要点击 窗口 ...
- Populating Next Right Pointers in Each Node(I and II)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...
- 经典Console案例
/*下面的示例演示 WindowLeft.WindowTop.WindowWidth.WindowHeight.BufferWidth.BufferHeight 和 CursorVisible 属性以 ...
- geth常用指令
ubuntu下载: https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu sudo apt ...
- FFPLAY的原理(五)
创建线程 Spawning Threads Overview Last time we added audio support by taking advantage of SDL's audio f ...
- CPA、CPS、CPM、CPT、CPC 是什么
http://www.a-edm.com/cpa.html 网络营销之所以越来越受到重视一个主要的原因就是因为“精准”.相比较传统媒体的陈旧广告形式,网络营销能为广告主带来更为确切的效果与回报,更有传 ...
- [Luogu 4135] 作诗
Description 神犇SJY虐完HEOI之后给傻×LYD出了一题: SHY是T国的公主,平时的一大爱好是作诗. 由于时间紧迫,SHY作完诗之后还要虐OI,于是SHY找来一篇长度为N的文章,阅读M ...
- ubuntu 18.04安装docker以及docker内配置neo4j
如题 切换到root用户下 apt install docker.io 等啊等,很快,就好了.. 如图 即可使用 如果出现Cannot connect to the Docker daemon at ...
- Redis的安装及学习
最近因为做Chatbot项目需要对于NoSQL数据库进行研究,调研范围包括MongoDB和Redis.本文将介绍Redis在Windows环境的安装及如何利用python来操作Redis数据库. Re ...
- Python_方法演示
class Root: __total=0 def __init__(self,v): #构造函数 self.__value=v Root.__total+=1 def show(self): #普通 ...