14. 水晶球

Description

和许多同龄女孩子一样,久莲也喜欢水晶球。

还有

天,就是心心念念的他生日了。

久莲希望把全世界最大最好看的水晶球送给他。

她找到了宝石收藏家亚瑟斯,希望能够寻求他的帮助。

亚瑟斯很快被打动了,拿出了精心收集的块美丽的水晶石,这些水晶石初始是长宽高分别

 

 

#include "stdio.h"
#include "stdlib.h"
struct _ball
{
    long long a;
    long long b;
    long long c;
    long number;
} ball[100005];
int cmp(const void *a, const void *b)
{
    struct _ball x = *(struct _ball *)a;
    struct _ball y = *(struct _ball *)b;
    if(x.a != y.a)
    {
        return x.a - y.a;
    }
    
    else
    {
        if(x.b!=y.b)
            return x.b - y.b;
        
        else
        {
            return x.c - y.c;
        }
        
    }
}
int main()
{
    long n;
    scanf("%ld", &n);
    for (long i = 0; i < n; i++)
    {
        long long t;
        scanf("%lld %lld %lld", &ball[i].a, &ball[i].b, &ball[i].c);
        ball[i].number = i;
        if(ball[i].a < ball[i].b) //ćšć>
        {
            t = ball[i].a;
            ball[i].a = ball[i].b;
            ball[i].b = t;
        }
        if(ball[i].b < ball[i].c)
        {
            t = ball[i].b;
            ball[i].b = ball[i].c;
            ball[i].c = t;
        }
        if(ball[i].a < ball[i].b)
        {
            t = ball[i].b;
            ball[i].b = ball[i].a;
            ball[i].a = t;
        }
    }
    qsort(ball, n, sizeof(struct _ball), cmp);
    long long max = 0, max1 = 0, max2 = 0;
    long p1, p0, p2;
    for (long i = 0; i < n; i++)
    {
        if(ball[i].c > max)
        {
            max = ball[i].c;
            p0 = ball[i].number;
        }
            
    }
    for (long i = 0; i < n-1; i++)
    {
        if(ball[i].a == ball[i+1].a && ball[i].b == ball[i+1].b)
        {
            max2 = ball[i].c + ball[i + 1].c;
            if(ball[i].b < max2)
            {
                max2 = ball[i].b;
            }
            if(max2 > max1)
            {
                p1 = ball[i].number;
                p2 = ball[i+1].number;
                max1 = max2;
            }
            else
                continue;
        }
    }
    if(max >= max1)
    {
        printf("1\n%ld\n", p0 + 1);
    }
    
    else
    {
        printf("2\n%ld %ld\n", p2 + 1, p1 + 1);
    }
    
}

 

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值