Test instructions: Give the city (0,0), give the n coordinates, the starting number s, each coordinate k person, each coordinate can be covered to the radius of the area of R, R=sqrt (x*x+y*y) area, ask the minimum radius is how much, so that the total number of cities is greater than or equal to 1000000
The first is the sort, greedy to do, found that the accuracy of sqrt is not up to the requirements, so turned over the code
So I found out with a map that we could solve.
Map<int,int>,it->first is the content of the first int, It->second is the content of the second int
The words originally are to follow the label to find, want to do two points to find the title = =
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=100005; - - intMain () { + intn,s; -map<int,int>CNT; +scanf"%d%d",&n,&s); A intx,y,k; at for(intI=1; i<=n;i++){ -Cin>>x>>y>>K; -cnt[x*x+y*y]+=K; - } - - for(map<int,int>::iterator It=cnt.begin (); It!=cnt.end (); + +it) { inS+=it->second; - if(s>=1000000){ toprintf"%lf\n", sqrt (it->First )); + return 0; - } the } *printf"-1\n"); $ return 0;Panax Notoginseng}
View Code
Codeforces 424 B Megacity "greedy"