http://codeforces.com/contest/702

题意:n个村庄,m个机站,问机站最短半径覆盖完所有村庄

思路:直接二分答案

二分太弱,调了半天。。。。。

 // #pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define pi acos(-1.0)
const int N = 1e5+;
const int MOD = 1e9+;
#define inf 0x7fffffff
typedef long long LL; void frein(){freopen("in.txt","r",stdin);}
void freout(){freopen("out.txt","w",stdout);}
inline int read(){int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-;ch=getchar();}while(ch>=''&&ch<='') { x=x*+ch-'';ch=getchar();}return x*f;} int a[N];
int b[N]; int main(){
// frein();
// freout();
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=m;i++) scanf("%d",&b[i]);
LL l=,r=2e9;
while(l<r){
LL mid=(l+r)>>;
int j=;
bool flag=false;
for(int i=;i<=n;i++){
if(j>m){
flag=true;
break;
}
if(fabs(b[j]-a[i])<=mid){
continue;
}
else{
j++;
i--;
}
}
if(flag){
l=mid+;
}
else{
r=mid;
}
}
printf("%I64d\n",l);
return ;
}

codeforce 702C Cellular Network 二分答案的更多相关文章

  1. Codeforces 702C Cellular Network(二分)

    题目链接:http://codeforces.com/problemset/problem/702/C 题意: 在数轴上有N个城市和M个信号塔,给你这N个城市以及M个塔在数轴上的位置,求M个塔可以覆盖 ...

  2. codeforces 702C Cellular Network 2016-10-15 18:19 104人阅读 评论(0) 收藏

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces 702C Cellular Network

    题目:这里 题意:一条数轴上,有n个城市和m个塔,分别给出城市的位置和塔的位置,每个塔有个覆盖范围,问能将所有城市都覆盖的塔的最小范围是多少,一个城市只要被至少一个塔 覆盖就行. 可以利用贪心的思想模 ...

  4. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  5. codeforces 702C C. Cellular Network(水题)

    题目链接: C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input st ...

  6. Educational Codeforces Round 15 Cellular Network

    Cellular Network 题意: 给n个城市,m个加油站,要让m个加油站都覆盖n个城市,求最小的加油范围r是多少. 题解: 枚举每个城市,二分查找最近的加油站,每次更新答案即可,注意二分的时候 ...

  7. Educational Codeforces Round 15_C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. cf702C Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. bzoj 3597 [Scoi2014] 方伯伯运椰子 - 费用流 - 二分答案

    题目传送门 传送门 题目大意 给定一个费用流,每条边有一个初始流量$c_i$和单位流量费用$d_i$,增加一条边的1单位的流量需要花费$b_i$的代价而减少一条边的1单位的流量需要花费$a_i$的代价 ...

随机推荐

  1. Splunk常用命令

    重启/查看状态/停止splunk [root@localhost splunk]# /opt/splunk/bin/splunk restart / status / stop

  2. js判断浏览器类型 js判断ie6不执行

    js判断浏览器类型 $.browser  对象 $.browser.version 浏览器版本 var binfo = ''; if ($.browser.msie) { binfo = " ...

  3. netty 解决TCP粘包与拆包问题(三)

    今天使用netty的固定长度进行解码 固定长度解码的原理就是按照指定消息的长度对消息自动解码. 在netty实现中,只需要采用FiexedLengthFrameDecoder解码器即可... 以下是服 ...

  4. GridView官方教程及示例

    Grid View GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The gri ...

  5. Windows Tomcat 安装

    JDK的安装可以参考 http://www.cnblogs.com/emanlee/p/3702535.html ,然后安装apache-tomcat step1:http://tomcat.apac ...

  6. Effective C++学习笔记 条款04:确定对象被使用前已先被初始化

    一.为内置类型对象进行手工初始化,因为C++不保证初始化它们. 二.对象初始化数据成员是在进入构造函数用户编写代码前完成,要想对数据成员指定初始化值,那就必须使用初始化列表. class A { pu ...

  7. Redis cluster学习 & Redis常识 & sort操作

    Redis中的5种数据类型String.Hash.List.Set.Sorted Set. Redis源码总代码一万多行. 这篇文章有一些Redis "常识" http://www ...

  8. sdut 2831 Euclid (几何)

    题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2831 题意:给a, b,  c,  d, ...

  9. Instruments-查看收集到的数据

    由于Xcode调试工具Instruments指南篇幅太长,所以本篇blog继续上篇,介绍对Instruments收集到的数据去分析. 关于数据分析 Instruments不解决你代码中的任何问题,它帮 ...

  10. Spring MVC 的请求参数获取的几种方法

    通过@PathVariabl注解获取路径中传递参数 @RequestMapping(value = "/{id}/{str}") public ModelAndView hello ...