Codeforces 702C Cellular Network】的更多相关文章

C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line - the positions (x-coordinates) of the cities and m points on the same line…
题目链接:http://codeforces.com/problemset/problem/702/C 题意: 在数轴上有N个城市和M个信号塔,给你这N个城市以及M个塔在数轴上的位置,求M个塔可以覆盖N个城市的最小半径r. 思路: 刚开始想的是,对半径进行二分,但是考虑到每次对半径进行二分后,要判断这M个塔是否已经可以覆盖N个城市,判断这里找不到时间复杂度比较好的写法.后面想了想,对于每个城市,找到距离其最近的塔,计算出距离,在这N个距离中取最大的距离,就是最后要找的最小半径r了,这里同样利用二…
题目:这里 题意:一条数轴上,有n个城市和m个塔,分别给出城市的位置和塔的位置,每个塔有个覆盖范围,问能将所有城市都覆盖的塔的最小范围是多少,一个城市只要被至少一个塔 覆盖就行. 可以利用贪心的思想模拟一下,注意一下细节就行,也可以二分. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<map> using namespace s…
http://codeforces.com/contest/702 题意:n个村庄,m个机站,问机站最短半径覆盖完所有村庄 思路:直接二分答案 二分太弱,调了半天..... // #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include <cstring> #include <sstream>…
题目链接: C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same…
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line…
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line…
Cellular Network 题意: 给n个城市,m个加油站,要让m个加油站都覆盖n个城市,求最小的加油范围r是多少. 题解: 枚举每个城市,二分查找最近的加油站,每次更新答案即可,注意二分的时候不要越界oil数组,上下界都不要越.还有,int坑死人,以后绝对全用long long!!! 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; cons…
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line…
Cellular Network CodeForces - 702C 给定 n (城市数量) 和 m (灯塔数量): 给定 a1~an 城市坐标: 给定 b1~bm 灯塔坐标: 求出灯塔照亮的最小半径 r ,使得所有城市都能被照亮. Input 3 2-2 2 4-3 0 Output 4 Input 5 31 5 10 14 174 11 15 Output 3 题解: 首先对于每个城市 a[ i ],找到离它最近的左右两个灯塔  b [ x ] , b [ x-1 ](只有最左或最右灯塔时…