HackerRank "Flatland Space Stations"
A bit Greedy can achieve O(m) - the mid station between 2 adjacent cities has the longest distance within that range.
#include <vector>
#include <iostream>
using namespace std; int main(){
int n;
int m;
cin >> n >> m;
vector<int> c(m);
for(int c_i = ;c_i < m;c_i++){
cin >> c[c_i];
}
sort(c.begin(), c.end());
int r = ;
for(int i =; i < m - ; i ++)
{
r = max(r, (c[i + ] - c[i])/);
}
r = max(r, c[]);
r = max(r, n - c.back() - );
cout << r << endl; return ;
}
HackerRank "Flatland Space Stations"的更多相关文章
- BZOJ2527: [Poi2011]Meteors
补一发题解.. 整体二分这个东西,一开始感觉复杂度不是很靠谱的样子 问了po姐姐,说套主定理硬干.. #include<bits/stdc++.h> #define ll long lon ...
- 【BZOJ-2527】Meteors 整体二分 + 树状数组
2527: [Poi2011]Meteors Time Limit: 60 Sec Memory Limit: 128 MBSubmit: 831 Solved: 306[Submit][Stat ...
- BZOJ_2527_[Poi2011]Meteors_整体二分
BZOJ_2527_[Poi2011]Meteors_整体二分 Description Byteotian Interstellar Union (BIU) has recently discover ...
- BZOJ2527[Poi2011]Meteors——整体二分+树状数组
题目描述 Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The ...
- Game Development Patterns and Best Practices (John P. Doran / Matt Casanova 著)
https://github.com/PacktPublishing/Game-Development-Patterns-and-Best-Practices https://github.com/m ...
- 【bzoj 2527】[Poi2011]Meteors
Description Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby gala ...
- bzoj 2527 Meteors - 整体二分 - 树状数组
Description Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby gala ...
- SPOJ Meteors - 可持久化线段树 - 二分法
Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The plan ...
- CH4912 Meteors
题意 4912 Meteors 0x49「数据结构进阶」练习 描述 Byteotian Interstellar Union有N个成员国.现在它发现了一颗新的星球,这颗星球的轨道被分为M份(第M份和第 ...
随机推荐
- Thinkpad T420 指纹开机 win10 解决方案
以前没感觉笔记本上的指纹有什么用,后来无意看到了指纹能开机.便尝试把这个功能给用起来.果然麻烦了些. 1.官网上没有win10的指纹应用软件. 下载了win8的版本,安装后没有问题,可以登录win10 ...
- Javascript、CSS和IMG之网页执行探索
测试环境:windows/chrome 实例1:页面中仅有图片 <html xmlns="http://www.w3.org/1999/xhtml"> <head ...
- html默认属性
对于display为block来说width默认是满长的,即父级得100%,而高度是0,除非手动设置为100%或指定高度.
- 两个list取不同值
转自同名博文,未知真正出处,望作者见谅 如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素 ...
- 关于java中static的应用及一种常见错误
JAVA中的static的应用 在web项目的开发中,遇到了类中的static方法不奏效. 在开发过程中,我定义了一个静态方法初始化数组,但是在创建类的对象后,访问该数组是全为null.我一直以为st ...
- Recylerview的使用系列教程
转发自:http://edu.csdn.net/course/detail/2877
- Dos学习笔记(3)attrib命令
今天和昨天一直在摸索这个命令觉得这个命令为什么改变不了文件夹的属性, 因为我试着用attrib +r /s 去修改子文件夹的时候发现没用,然后如果输入 attrib +r /d 又提示说/d需要和/s ...
- 灰色蓝色系简洁自适应登录HTML页面
自己写了一个简介的登录页面,页面背景为灰色,居中为登录框,登录面板为半透明效果,整体十分美观,登录按钮有JS效果.自己感觉还不错,拿出来分享一下. 页面效果图 源码下载链接:http://files. ...
- Ubuntu配置VNC server
安装vncserver后,默认的配置下只有一个很"朴素"的图形界面(没有抓图,就一个黑白窗口),要支持Ubuntu的桌面,并且支持和windows之前复制粘贴文字,需要修改xsta ...
- commonJS
摘自阮一峰博客:http://javascript.ruanyifeng.com/nodejs/module.html 目录 概述 module对象 module.exports属性 exports变 ...