http://codeforces.com/contest/702
Test instructions: N villages, m stations, ask the station the shortest radius cover all villages
Idea: Direct two-point answer
Two points is too weak, adjusted for half a day .....
1 //#pragma COMMENT (linker, "/stack:102c000000,102c000000")2#include <iostream>3#include <cstdio>4#include <cstring>5#include <sstream>6#include <string>7#include <algorithm>8#include <list>9#include <map>Ten#include <vector> One#include <queue> A#include <stack> -#include <cmath> -#include <cstdlib> the //#include <conio.h> - using namespacestd; - #definePi ACOs (-1.0) - Const intN = 1e5+Ten; + Const intMOD = 1e9+7; - #defineINF 0x7fffffff +typedefLong LongLL; A at voidFrein () {freopen ("In.txt","R", stdin);} - voidFreout () {freopen ("OUT.txt","W", stdout);} -InlineintRead () {intx=0, f=1;CharCh=getchar (); while(ch>'9'|| ch<'0') {if(ch=='-') f=-1; Ch=getchar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; Ch=getchar ();}returnx*F;} - - intA[n]; - intB[n]; in - intMain () { to //Frein (); + //freout (); - intn,m; thescanf"%d%d",&n,&m); * for(intI=1; i<=n;i++) scanf ("%d",&a[i]); $ for(intI=1; i<=m;i++) scanf ("%d",&b[i]);Panax NotoginsengLL l=0, r=2e9; - while(l<R) { theLL mid= (l+r) >>1; + intj=1; A BOOLflag=false; the for(intI=1; i<=n;i++){ + if(j>m) { -flag=true; $ Break; $ } - if(Fabs (B[j]-a[i]) <=mid) { - Continue; the } - Else{WuyiJ + +; thei--; - } Wu } - if(flag) { AboutL=mid+1; $ } - Else{ -R=mid; - } A } +printf"%i64d\n", L); the return 0; -}
Codeforce 702C Cellular Network Two-point answer