codeforces|Megacity

题目意思在0,0点开始想要找到 大于1e6 的最小的最大半径
【codeforces|Megacity】如果找不到输出-1

#include"bits/stdc++.h" #define ll long long #define pi pair #define inf 0x3f3f3f3f #define_for(i,a,b) for(int i=a; i<=b; i++) #definefor_(i,a,b) for(int i=a; imp; struct node{ int x; double y; }a[N]; bool cmp(node s1,node s2){ if(s1.y != s2.y) return s1.ys2.x; } void solve(){ int n,m; cin >> n >> m; for_(i,0,n){ int xx,yy; cin >> xx >> yy >> a[i].x; a[i].y= sqrt(xx*xx+yy*yy); } sort(a,a+n,cmp); bool f=true; double ans = 0; for_(i,0,n){ m+=a[i].x; if(m>=1000000){ f= false; ans = a[i].y; break; } } if(f) cout << -1 << endl; else printf("%.7f\n",ans); } int main(){ IOS; solve(); return 0; }


    推荐阅读