Codeforces Round #242 (Div. 2) B. Megacity
来源:互联网 发布:淘宝靠谱的三星手机店 编辑:程序博客网 时间:2024/05/17 22:58
思路:对于所有给定点算出到原点的距离,然后排序,采用贪心思想,从小到大的扩充人数,直至到达one million
#include <stdio.h>#include <iostream>#include <string>#include <string.h>#include <algorithm>#include <stdlib.h>#include <math.h>#include <vector>#include <map>using namespace std;const int maxn = 1000000;map<double, int>mp;double dist(int x,int y){ if(x < 0) x = -x; if(y < 0) y = -y; return sqrt(x*x + y*y);}int main(){ int n,s; while(~scanf("%d%d",&n,&s)){ int x,y,k; for(int i = 0;i < n;i++){ scanf("%d%d%d",&x,&y,&k); mp[dist(x, y)] += k; } map<double, int>::iterator it; double ans = -1; for(it = mp.begin();it != mp.end();it++){ if(s >= maxn) break; s += it->second; ans = it->first; //printf("%.7lf %d\n",it->first,it->second); } if(s < maxn) printf("-1\n"); else printf("%.7lf\n",ans); } return 0;}
0 0
- Codeforces Round #242 (Div. 2) B. Megacity
- Codeforces Round #242 (Div. 2) B. Megacity
- Codeforces Round #242 (Div. 2) B. Megacity
- codeforces#242B-Megacity-二分
- codeforces 424B Megacity
- Codeforces Round #242 (Div. 2) (A、B、C)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Codeforces Round #203 (Div. 2) B. Resort
- Codeforces Round #206 (Div. 2) - b
- MongoDB安装\连接
- 如何评估temporary tablespace的extent size??
- Asp.net直接保存文件到客户端
- 20140426 【DP - 状态压缩】 POJ 1753 Flip Game
- ab --- apache自带的压力测试工具 (apache benchmark )使用
- Codeforces Round #242 (Div. 2) B. Megacity
- tar命令的C参数
- bootstrap响应式导航
- linux 常用命令及技巧
- 在ASP.NET Atlas中调用Web Service
- 动画杂记
- 昨天面试小结
- ASP.NET中自定义提示对话框
- spring factory-method和factory-bean 使用