bzoj3969 [WF2013]Low Power
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3969
【题解】
二分答案x,贪心选取,如果选取了i个,有j对,那么要满足i<=2*j*k(不然有数就没位置放了)
# include <stdio.h>
# include <string.h>
# include <iostream>
# include <algorithm>
// # include <bits/stdc++.h> using namespace std; typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = 2e6 + ;
const int mod = 1e9+; # define RG register
# define ST static int n, k, N;
int a[M]; inline bool chk(int x) {
int times = ;
for (int i=; i<=N; ++i) {
if(i- > *times*k) return false;
if(i <= N && a[i+] - a[i] <= x) ++i, ++times;
if(times == n) return ;
}
return false;
} int main() {
cin >> n >> k; N = *n*k;
for (int i=; i<=N; ++i) scanf("%d", a+i);
sort(a+, a+N+);
int l = a[] - a[], r = 1e9, ans;
while() {
if(r-l <= ) {
for (int i=l; i<=r; ++i) {
if(chk(i)) {
ans = i;
break;
}
}
break;
}
int mid = l+r>>;
if(chk(mid)) r = mid;
else l = mid;
}
cout << ans << endl;
return ;
}
bzoj3969 [WF2013]Low Power的更多相关文章
- 【二分贪心】Bzoj3969 [WF2013] Low Power
Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能量之差越小,这个机器就工作的越好. 现在有2nk个电池,已知它们的 ...
- bzoj 3969: [WF2013]Low Power 二分
3969: [WF2013]Low Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...
- 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 ...
- BZOJ_3969_[WF2013]Low Power_二分答案
BZOJ_3969_[WF2013]Low Power_二分答案 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能 ...
- 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 ...
随机推荐
- Ubuntu16.04下配置ssh免密登录
Ubuntu16.04下配置ssh免密登录 环境准备:新建两台虚拟机,而且两台虚拟机上都装有Ubuntu16.04的系统,使两台虚拟机之间保持互通状态.分别为两台虚拟机命名为A,B.假设我们要使A虚拟 ...
- MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':ge
数据库表里命名有这个字段,可怎么就是报错呢,大神的解释: 加上之后立马好用!!!
- Spring---配置文件概述
概述 Spring 的配置文件是用于指导 Spring 工厂进行Bean的生产.依赖关系注入及 Bean 实例分发的“图纸”,它是一个或多个标准的XML文档,J2EE 程序员必须学会并灵活应用这份“图 ...
- Javascript Step by Step - 01
基本数据类型 简单数值类型: undefined, null, boolean, number和string,共有5种 复合数据类型:object,array,function typeof操作符用来 ...
- 2599: [IOI2011]Race
2599: [IOI2011]Race 链接 分析 被memset卡... 点分治,对于重心,遍历子树,记录一个数组T[i],表示以重心为起点的长度为i的路径中最少的边数是多少.然后先遍历子树,更新答 ...
- android 获取图片
Android获取手机或者内存卡里面的图片有两种方式 1.这是通过一种action Intent intent=new Intent(); intent.setAction(Intent.ACTION ...
- cycling -avoid the vicious cycle
‘Numerous' studies in the past appear to have shown a link between cycling and ED. The researchers a ...
- 我的转行之路(电气转IT)------2018阿里校招面经
博主本专业电气,今年3月下定决心转向互联网行业,本来想依仗自己比较自信的学习能力自学成才的,不过学了一段时间感觉还是需要一个人来指点,不仅仅是指点一些技术性的问题,更是需要有人来指点一下方向性的问题. ...
- 《Cracking the Coding Interview》——第13章:C和C++——题目10
2014-04-25 20:47 题目:分配一个二维数组,尽量减少malloc和free的使用次数,要求能用a[i][j]的方式访问数据. 解法:有篇文章讲了六种new delete二维数组的方式,其 ...
- python /usr/bin/python^M: bad interpreter: No such file
今天在WingIDE下写了个脚本,传到服务器执行后提示: -bash: /usr/bin/autocrorder: /usr/bin/python^M: bad interpreter: No suc ...