Codeforces 424 B Megacity "greedy"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.