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份和第 ...
随机推荐
- The first day to learn Englisht
IF you want to go fast,to alone. IF you want to go far,go with others.
- UVA 572 油田连通块-并查集解决
题意:8个方向如果能够连成一块就算是一个连通块,求一共有几个连通块. 分析:网上的题解一般都是dfs,但是今天发现并查集也可以解决,为了方便我自己理解大神的模板,便尝试解这道题目,没想到过了... # ...
- amazon oa2 - insert a value into a cycled linked list
遍历,一共有三种情况, 1. pre <= x <= current 2. 遍历到了head时,x>tail 或者 x<=head (不会等于tail) 3. 遍历回aNode ...
- Linux下mysql忘记root密码
一台机器上的MYSQL服务器很久没用了,忘了root密码无法连接.一时情急,网上搜寻办法,解决,记录在此备用. 修改MySQL的登录设置: //不同的版本的Linux配置文件的位置也不一样,以Lin ...
- Ported my old SPH solver in Unity
Here is the link to the web player version, http://www-scf.usc.edu/~taian/pages/sph/builds/12212014/ ...
- 系统弹性概念[TODO]
系统弹性 Shopify构建分布式可扩展应用的最佳实践 [编者的话]在构建大型分布式系统应用时,如何降低不同部分之间的依赖,增强系统的弹性,电商解决方案提供商 Shopify 给出了解决方法. 弹性矩 ...
- iconv 失败
网上的都是这样用的 代码如下: $content = iconv("utf-8","gb2312",$content); 这样做其实也 ...
- 获取select标签选中状态 的label的值。
<select name="procode" onchange="alert(this.options[this.selectedIndex].text)" ...
- Hadoop集群搭建安装过程(二)(图文详解---尽情点击!!!)
Hadoop集群搭建安装过程(二)(配置SSH免密登录)(图文详解---尽情点击!!!) 一.配置ssh无密码访问 ®生成公钥密钥对 1.在每个节点上分别执行: ssh-keygen -t rsa(一 ...
- 微信公众号开发之被逼学web服务端1-----使用SecureCRT连接Linux服务器
做Android的进新公司后安排做微信公众号开发,这基本是后台和前端的活都要由小白的我来做,这两天基本成鸭子了,被填的满满的,却还是不够,博文仅作记录,希望能给后来的小白一点参考吧 今天做的是如何配置 ...