Codeforces Round #242 (Div. 2) B. Megacity
按照半径排序,然后累加人数直到超过百万
#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的更多相关文章
- Codeforces Round #242 (Div. 2) C题
题目链接:http://codeforces.com/contest/424/problem/C, 想来一个小时,就是做不出,都做出来了,悲剧! 分析:我们知道交换异或的顺序不影响答案! 然后就是求t ...
- Codeforces Round #242 (Div. 2) A~C
题目链接 A. Squats time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputou ...
- Codeforces Round #242 (Div. 2) <A-D>
CF424 A. Squats 题目意思: 有n(n为偶数)个x和X,求最少的变换次数,使得X的个数为n/2,输出变换后的序列. 解题思路: 统计X的个数ans,和n/2比較,少了的话,须要把n/2- ...
- Codeforces Round #242 (Div. 2) A. Squats
注意题目一次只能改变一个松鼠,Pasha can make some hamster ether sit down or stand up.是单数不是复数 #include <iostream& ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas
解题思路是: Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^.... 故Q的求解过程分成两部分 第一 ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas (位异或性质 找规律)
题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1. 交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ ...
- Codeforces Round #242 (Div. 2)C(找规律,异或运算)
一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- jq 确定删除方法与文件删除
var choice=confirm("您确认要删除吗?", function() { }, null); if(choice) ...
- Visual Studio 推荐插件--高量,变量高量,语法高亮
1 WordLight for 2008 下载网址:http://visualstudiogallery.msdn.microsoft.com/ad686131-47d4-4c13-ada2-5b1 ...
- SQL分组和聚合(Grouping and Aggregates)
这章应该是难点,也是成为SQL高手的必经之路. 注意有GROUP 语句时,WHERE和HAVING的场合. 前者用于检索前的条件过滤 . 后者用于检索出来结果之后的条件过滤. ========== ; ...
- SQLAlchemy ORM之建表与查询
作了最基本的操作,找找感觉.. #coding=utf-8 from datetime import datetime from sqlalchemy import (MetaData, Table, ...
- scala中的抽象类
scala中也有和java,c#类似的抽象类,抽象类会有部分实现,也有没有实现的方法定义.抽象类最大的特征是不能直接实例化.下面我们看个例子. abstract class Animal { def ...
- 一致性hash算法简介与代码实现
一.简介: 一致性hash算法提出了在动态变化的Cache环境中,判定哈希算法好坏的四个定义: 1.平衡性(Balance) 2.单调性(Monotonicity) 3.分散性(Spread) 4.负 ...
- 通讯录(ios自带无界面)
1,添加框架AddressBook.framework 2,请求权限认证,在Appdelegate.m文件中 - (BOOL)application:(UIApplication *)applicat ...
- 孙鑫VC学习笔记:多线程编程
孙鑫VC学习笔记:多线程编程 SkySeraph Dec 11st 2010 HQU Email:zgzhaobo@gmail.com QQ:452728574 Latest Modified ...
- 已解决:Strict Standards: Non-static method cls_image::gd_version() should not be called statically in...
在安装Ecshop的时候,遇到两个⚠️问题: Strict Standards: Non-static method cls_image::gd_version() should not be cal ...
- Linux内核创建一个新进程的过程
“平安的祝福 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ” 进程在 ...