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 ...
随机推荐
- 面试中关于Redis的问题看这篇就够了
昨天写了一篇自己搭建redis集群并在自己项目中使用的文章,今天早上看别人写的面经发现redis在面试中还是比较常问的(笔主主Java方向).所以查阅官方文档以及他人造好的轮子,总结了一些redis面 ...
- SQLite3 使用教学
source: SQL中文站:http://www.sqlite.com.cn/MySqlite/4/378.Html OS X自从10.4后把SQLite这套相当出名的数据库软件,放进了作业系统工具 ...
- C# 加密解密以及sha256不可逆加密案例
class Program { static void Main(string[] args) { string aa = "身份证"; string bb = "key ...
- OAuth认证与授权
什么是OAuth授权? 一.什么是OAuth协议 OAuth(开放授权)是一个开放标准. 允许第三方网站在用户授权的前提下访问在用户在服务商那里存储的各种信息. 而这种授权无需将用户提供用户名和密 ...
- oracle日期格式转换 to_date()
与date操作关系最大的就是两个转换函数:to_date(),to_char() to_date() 作用将字符类型按一定格式转化为日期类型: 具体用法:to_date(''2 ...
- Java-悲观锁和乐观锁
Java中的乐观锁与悲观锁: 1. Java中典型的synchronized就是一种悲观锁,也就是独占锁,不过JDK1.6之后对synchronized已经做了许多优化,也不能说是完全的悲观锁了: 2 ...
- 使用Nginx代理Django
一.准备环境 检查python版本以及pip版本 [root@linux-node01 src]# python --version Python 2.7.5 [root@linux-node01 s ...
- Eolinker----全局变量的不同场景使用
因为目前eolinker的API自动化测试不支持“构造参数”,因此针对“全局变量”的使用在不同的场景下,可采用不同的方式实现,但是一个参数既然设计成为了全局变量,那么在接口中使用时尽量保证书写风格一致 ...
- [你必须知道的.NET]第十七回:貌合神离:覆写和重载
本文将介绍以下内容: 什么是覆写,什么是重载 覆写与重载的区别 覆写与重载在多态特性中的应用 1. 引言 覆写(override)与重载(overload),是成就.NET面向对象多态特性的基本技术之 ...
- oracle 12C wmsys.wm_concat()函数
http://blog.itpub.net/31392094/viewspace-2149577/