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"的更多相关文章

  1. BZOJ2527: [Poi2011]Meteors

    补一发题解.. 整体二分这个东西,一开始感觉复杂度不是很靠谱的样子 问了po姐姐,说套主定理硬干.. #include<bits/stdc++.h> #define ll long lon ...

  2. 【BZOJ-2527】Meteors 整体二分 + 树状数组

    2527: [Poi2011]Meteors Time Limit: 60 Sec  Memory Limit: 128 MBSubmit: 831  Solved: 306[Submit][Stat ...

  3. BZOJ_2527_[Poi2011]Meteors_整体二分

    BZOJ_2527_[Poi2011]Meteors_整体二分 Description Byteotian Interstellar Union (BIU) has recently discover ...

  4. BZOJ2527[Poi2011]Meteors——整体二分+树状数组

    题目描述 Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The ...

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

  6. 【bzoj 2527】[Poi2011]Meteors

    Description Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby gala ...

  7. bzoj 2527 Meteors - 整体二分 - 树状数组

    Description Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby gala ...

  8. SPOJ Meteors - 可持久化线段树 - 二分法

    Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The plan ...

  9. CH4912 Meteors

    题意 4912 Meteors 0x49「数据结构进阶」练习 描述 Byteotian Interstellar Union有N个成员国.现在它发现了一颗新的星球,这颗星球的轨道被分为M份(第M份和第 ...

随机推荐

  1. 新建jfinal2.2项目并连接mysql

    一新建项目 1. new→Dynamic  Web Project 2修改Default Output Folder.一般用WebRoot\WEB-INF\class,然后下一步(注意路径要写对,不然 ...

  2. 【转】javascript变量声明 及作用域

    javascript变量声明提升(hoisting) javascript的变量声明具有hoisting机制,JavaScript引擎在执行的时候,会把所有变量的声明都提升到当前作用域的最前面. 先看 ...

  3. collections系列

    一.计数器(counter) Counter是对字典类型的补充,用于追踪值的出现次数. ps:具备字典的所有功能 + 自己的功能 c = Counter('abcdeabcdabcaba') prin ...

  4. 深入解析Javascript中this关键字的使用

    深入解析Javascript中面向对象编程中的this关键字 在Javascript中this关键字代表函数运行时,自动生成的一个内部对象,只能在函数内部使用.比如: function TestFun ...

  5. Node.prototype.contains

    document.documentElement.contains(document.body) // true document.documentElement.compareDocumentPos ...

  6. Course Schedule

    There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prer ...

  7. robotframework接口测试初探3

    接口自动化环境搭建好了 requests接口测试模块也会用了 那么怎样整合到RF的框架呢? 写一个小例子

  8. 集成ShareSDK,分享成功后QQ和空间回调不执行的可能原因

    AndroidMainifest.xml中的如箭头所示的id与assets下ShareSDK.xml中配置的QQ的AppId一定要相同.

  9. springmvc学习笔记--ueditor和springmvc的集成

    前言: 在web开发中, 富文本的编辑器真心很重要. 有电商店铺的打理, 新闻稿/博客文章/论坛帖子的编辑等等, 这种所见即所的编辑方式, 大大方便了非技术人员从事互利网相关的工作. 因为手头有个小项 ...

  10. 用 pytube 爬取 youtube 视频

    这个方法比直接用浏览器插件逼格高点 1. 简介 需要用到 pytube 这个第三方库:https://github.com/nficano/pytube 这里只是把这个页面捡重要部分翻译了一下. py ...