传送门: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的更多相关文章

  1. 【二分贪心】Bzoj3969 [WF2013] Low Power

    Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能量之差越小,这个机器就工作的越好. 现在有2nk个电池,已知它们的 ...

  2. bzoj 3969: [WF2013]Low Power 二分

    3969: [WF2013]Low Power Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...

  3. 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- ...

  4. 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 ...

  5. BZOJ_3969_[WF2013]Low Power_二分答案

    BZOJ_3969_[WF2013]Low Power_二分答案 Description 有n个机器,每个机器有2个芯片,每个芯片可以放k个电池. 每个芯片能量是k个电池的能量的最小值. 两个芯片的能 ...

  6. Low Power之CPF/UPF

    1 CPF The Common Power Format is a standard promoted by the Low Power Coalition at Si2. CPF is also ...

  7. [CortexM0--stm32f0308]Low Power Mode

    问题描写叙述 stm32f0308正常是运行在Run mode下.这样的mode是在reset之后的默认模式.Low Power Mode.即低功耗模式.用于在IC空暇时能够考虑选择进入.使系统耗能减 ...

  8. PatentTips - Fast awake from low power mode

    BACKGROUND Electronic devices, such as electronic book readers ("eBook reader devices"), c ...

  9. 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 ...

随机推荐

  1. PHP审计(一)

    一.php中常见的危险函数和审计要点 危险函数(功能过于强大)    参数是否外部可控,有没有正确的过滤. PHP获取外界传入参数是通过下面几个全局函数的形式,所以审计参数传入经常要和下面几个变量打交 ...

  2. 图解HTTP总结(7)——确保Web安全的HTTPS

    HTTP 主要有这些不足, 例举如下.       通信使用明文( 不加密) , 内容可能会被窃听.       不验证通信方的身份, 因此有可能遭遇伪装. 无法证明报文的完整性, 所以有可能已遭篡改 ...

  3. 裸机——LCD

    1.先了解显示器们 CRT显示器 原理,使用电子轰击荧光粉实现显示. 特点,主动发光,颜色绚丽,但是大. 等离子显示器(PDP) 原理,在显示屏上排列上千个密封的小低压气体室,通过电流激发使其发出肉眼 ...

  4. easypoi 一行代码搞定excel导入导出

    开发中经常会遇到excel的处理,导入导出解析等等,java中比较流行的用poi,但是每次都要写大段工具类来搞定这事儿,此处推荐一个别人造好的轮子[easypoi],下面介绍下“轮子”的使用. pom ...

  5. CF797E. Array Queries

    a is an array of n positive integers, all of which are not greater than n. You have to process q que ...

  6. CSAcademy Palindromic Concatenation 字符串哈希

    题意: 题目链接 给出\(n\)个字符串,求有多少对\((i,j),i \neq j\)使得\(s_i\)与\(s_j\)拼起来是回文串 分析: 设\(s_i,s_j\)的长度分别为\(L_i, L_ ...

  7. 直接插入排序&希尔排序

    1.直接插入排序 时间复杂度O(n2) 工作原理: 通过构建有序序列,对于未排序数据,在已排序的序列中,从后向前扫描,找到相应的位置并插入. 插入排序在实现上,在从后向前扫描的过程中,需要反复把已排序 ...

  8. Visual Studio 2017 的 JavaScript 调试功能的关闭

    关闭方法其实很简单,Options => Debugging => General => Enable JavaScript debugging for ASP.NET (Chrom ...

  9. 剑指Offer - 九度1519 - 合并两个排序的链表

    剑指Offer - 九度1519 - 合并两个排序的链表2013-11-30 22:04 题目描述: 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则.(hi ...

  10. python selenium 练习 自动获取豆瓣阅读当前特价书籍 chrome 元素定位 窗口切换 元素过期

    豆瓣原创电子书每周推出数十本限时免费数目,一周免费期过后恢复原价.想着豆瓣原创书中有不少值得一看,便写了个脚本,免去一个个添加的烦恼. 使用了Windows下selenium+Python的组合,有较 ...