题解 | 小红的圆移动 | 【贪心】| 第一发理解反了
小红的圆移动
https://www.nowcoder.com/practice/3d7a2818ac5746f5baf795de99a17f45
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const double pi = acos(-1);
struct Node{
double x,y,r,v;
bool operator<(const Node& o)const {
return v<o.v;
}
}p[N];
int main() {
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>p[i].x>>p[i].y>>p[i].r;
double d = -sqrt(p[i].x*p[i].x+p[i].y*p[i].y)+p[i].r;
if(d>0){
p[i].v=d*p[i].r*p[i].r*pi;
}
}
sort(p+1,p+1+n);
double ans=0;
for(int i=1;i<=n-k;i++){
ans+=p[i].v;
}
cout<<fixed<<setprecision(12)<<ans<<"\n";
}
// 64 位输出请用 printf("%lld")
顺丰集团工作强度 382人发布