按照半径排序,然后累加人数直到超过百万

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
using namespace std; int main(){
int n,s;
cin >> n >>s;
map<double,int> a;
for(int i = ; i < n ; ++ i){
double x,y;
int people;
cin>> x >>y>>people;
double r = x*x+y*y;
if(a.find(r)!=a.end()) a[r]+=people;
else a.insert(make_pair(r,people));
}
map<double,int>::iterator iter = a.begin();
for(; iter!=a.end(); iter++){
s+=iter->second;
if(s >= ) break;
}
if(iter==a.end())cout<<-<<endl;
else printf("%0.6f\n",sqrt(iter->first));
}

本题采用c++的map比较方便,map自动按照半径排序,但在将半径作为键时,先不要开方,不然存入map中会损失精度

Codeforces Round #242 (Div. 2) B. Megacity的更多相关文章

  1. Codeforces Round #242 (Div. 2) C题

    题目链接:http://codeforces.com/contest/424/problem/C, 想来一个小时,就是做不出,都做出来了,悲剧! 分析:我们知道交换异或的顺序不影响答案! 然后就是求t ...

  2. Codeforces Round #242 (Div. 2) A~C

    题目链接 A. Squats time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputou ...

  3. Codeforces Round #242 (Div. 2) &lt;A-D&gt;

    CF424 A. Squats 题目意思: 有n(n为偶数)个x和X,求最少的变换次数,使得X的个数为n/2,输出变换后的序列. 解题思路: 统计X的个数ans,和n/2比較,少了的话,须要把n/2- ...

  4. Codeforces Round #242 (Div. 2) A. Squats

    注意题目一次只能改变一个松鼠,Pasha can make some hamster ether sit down or stand up.是单数不是复数 #include <iostream& ...

  5. Codeforces Round #242 (Div. 2) C. Magic Formulas

    解题思路是: Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^.... 故Q的求解过程分成两部分 第一 ...

  6. Codeforces Round #242 (Div. 2) C. Magic Formulas (位异或性质 找规律)

    题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1.  交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ ...

  7. Codeforces Round #242 (Div. 2)C(找规律,异或运算)

    一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典 ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. ListView + PopupWindow实现滑动删除

    原文:ListView滑动删除 ,仿腾讯QQ(鸿洋_) 文章实现的功能是:在ListView的Item上从右向左滑时,出现删除按钮,点击删除按钮把Item删除. 看过文章后,感觉没有必要把dispat ...

  2. wifi参考网站

    1.Wireless LAN resources for Linux http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Wireless.htm ...

  3. [LeetCode] Word Pattern

    Word Pattern Total Accepted: 4627 Total Submissions: 17361 Difficulty: Easy Given a pattern and a st ...

  4. [LeetCode] Remove Duplicates from Sorted Array

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  5. Python多版本共存之pyenv

    经常遇到这样的情况: 系统自带的Python是2.6,自己需要Python 2.7中的某些特性: 系统自带的Python是2.x,自己需要Python 3.x: 此时需要在系统中安装多个Python, ...

  6. Effective C++ 之 Item 2:尽量以 const, enum, inline 替换 #define

    Effective C++ Chapter 1. 让自己习惯C++(Accustoming Yourself to C++) Item 2. 尽量以 const, enum, inline 替换 #d ...

  7. 发送http请求get方法

    //获取网页html NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"]; NSMutableURLRequest ...

  8. wpf template的code写法

    this.Template = XamlReader.Load ("<ControlTemplate xmlns='http://schemas.microsoft.com/clien ...

  9. r0遍历系统进程方法总结

    方法1: ZwQuerySystemInformation 这个方法网上一搜一大堆,不举例了 方法2:暴力枚举PID枚举进程,代码: NTSTATUS DriverEntry(PDRIVER_OBJE ...

  10. 软考之PV操作(同步)

    这几天,陆续有那么三两个同学跟我讨论了一下关于软考上的PV操作的题,吾虽不才,但还是把同学们讲通了,在此,特分享一下自己的思路和想法,愿对大家有点帮助! 下面,我们就通过自己做过的试卷上两道题来分析: ...