文章
39
粉丝
74
获赞
1
访问
18.2k
#include <stdio.h>
#include <stdlib.h>
int max(int a,int b){
if(a>=b)return a;
else return b;
}
typedef struct node{
int r;
int h;
}node;
struct node yuan[10000];
struct node back[10000];
int n;
int k;
int cmp(const void*a,const void*b){
struct node a1=*(struct node*)a;
struct node b1=*(struct node*)b;
return 2*b1.r*b1.h-2*a1.r*a1.h;
}
int work(int x){
int m=0;
for(int i=0;i<n;i++){
if(yuan[i].r<=yuan[x].r&&i!=x){
back[m++]=yuan[i];
}
}
if(m<k-1)return 0;
qsort(back,m,sizeof(struct node),cmp);
int sum=0;
for(int i=0;i<k-1;i++){
sum+=2*back[i].r*back[i].h;
}
sum+=2*yuan[x].r*yuan[x].h+yuan[x].r*yuan[x].r;
return sum;
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
scanf("%d %d",&yuan[i].r,&yuan[i].h);
}
int ans=0;
for(int i=0;i&...
登录后发布评论
暂无评论,来抢沙发