Megacity

题目意思  在0,0点开始   想要找到 大于1e6 的最小的最大半径

如果找不到输出-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++)
#define  for_(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;
}

你可能感兴趣的:(codeforces,c++)