bzoj 3969: [WF2013]Low Power 二分
3969: [WF2013]Low Power
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://www.lydsy.com/JudgeOnline/problem.php?id=3969
Description
Input
Output
一行一个整数,表示所有机器的能量之差的最大值最小是多少。
Sample Input
1 2 3 4 5 6 7 8 9 10 11 12
Sample Output
HINT
2nk <= 10^6, 1 <= pi <= 10^9。
题意
题解:
排序之后二分答案
check 是否前2ik个数里面至少有i个对满足题意的数
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1000001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
/* inline void P(int x)
{
Num=0;if(!x){putchar('0');puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
*/
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int n,m,k;
int a[maxn];
int l,r,mid;
bool check(int x)
{
for(int p=,q=;q<n;++p)
{
if(p->q**k)
return false;
if(a[p+]-a[p]<=x)
++p,++q;
}
return true;
}
int main()
{
n=read(),k=read();
m=*n*k;
l=,r=;
for(int i=;i<=m;i++)
{
a[i]=read();
r=max(r,a[i]);
}
sort(a+,a+m+);
while(l<r)
{
mid=(l+r)>>;
if(check(mid))
r=mid;
else
l=mid+;
}
printf("%d\n",l);
}
bzoj 3969: [WF2013]Low Power 二分的更多相关文章
- BZOJ_3969_[WF2013]Low Power_二分答案
		
BZOJ_3969_[WF2013]Low Power_二分答案 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能 ...
 - bzoj3969 [WF2013]Low Power
		
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3969 [题解] 二分答案x,贪心选取,如果选取了i个,有j对,那么要满足i<=2*j* ...
 - 【二分贪心】Bzoj3969 [WF2013] Low Power
		
Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能量之差越小,这个机器就工作的越好. 现在有2nk个电池,已知它们的 ...
 - 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 ...
 - Low Power之CPF/UPF
		
1 CPF The Common Power Format is a standard promoted by the Low Power Coalition at Si2. CPF is also ...
 - [CortexM0--stm32f0308]Low Power Mode
		
问题描写叙述 stm32f0308正常是运行在Run mode下.这样的mode是在reset之后的默认模式.Low Power Mode.即低功耗模式.用于在IC空暇时能够考虑选择进入.使系统耗能减 ...
 - PatentTips - Fast awake from low power mode
		
BACKGROUND Electronic devices, such as electronic book readers ("eBook reader devices"), c ...
 - Network management system scheduling for low power and lossy networks
		
In one embodiment, a network management system (NMS) determines an intent to initialize a request-re ...
 
随机推荐
- ISG2018 web题Writeup
			
0x01.命令注入 这题可以使用burpsuite扫出来,但是可能需要测一下. 得知payload为:i%7cecho%20gzavvlsv9c%20q9szmriaiy%7c%7ca%20%23'% ...
 - 自动化运维工具SaltStack详细部署【转】
			
==========================================================================================一.基础介绍==== ...
 - Mac 终端自动补全忽略大小写
			
打开终端,输入:nano .inputrc 在里面粘贴上以下语句: set completion-ignore-case onset show-all-if-ambiguous onTAB: menu ...
 - caffe Python API 之可视化
			
一.显示各层 # params显示:layer名,w,b for layer_name, param in net.params.items(): print layer_name + '\t' + ...
 - (五)Spring 对事务的支持
			
第一节:事务简介 满足一下四个条件: 第一:原子性: 第二:一致性: 第三:隔离性: 第四:持久性: ------------------------------------------------- ...
 - jenkins+docker持续集成实验
			
在互联网时代,对于每一家公司,软件开发和发布的重要性不言而喻,目前已经形成一套标准的流程,最重要的组成部分就是持续集成(CI)及持续部署.交付(CD).本文基于Jenkins+Docker+Git实现 ...
 - 深度学习方法(九):自然语言处理中的Attention Model注意力模型
			
欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.NET/xbinworld. 技术交流QQ群:433250724,欢迎对算法.技术感兴趣的同学加入. 上一篇博文深度学习方法(八):Enc ...
 - 更换 ECharts 散点图图标(散点图中symbol的使用)
			
更换 ECharts 散点图图标 使用symbol关键字
 - MySQL常用知识
			
1.MySQL常用引擎有哪些? A:MySQL常用的引擎有InnoDB.MyISAM.Memory,默认时InnoDB InnoDB:磁盘表,支持事务,支持行级锁,B+Tree索引 优点:具有良好的A ...
 - python log的处理方式
			
python log的处理方式 配置文件 #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "Q1mi" ...