首页 > 代码库 > codeforces 733D

codeforces 733D

明白了自己这么菜的原因多半是赛后不肯去补那些需要多花点时间思考的题目以及效率不高,但愿现在还不算晚。。。

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string.h>
#define maxint 999999999
#define MAXN 999999
typedef long long ll;
using namespace std;
bool vis[MAXN];
int n,m,k;
int num1[MAXN];
char str[MAXN];
struct node{
    ll a,b,c,num;
}sqr[MAXN];

bool cmp(node x,node y)
{
    if(x.a==y.a)
        return x.b>y.b;
    else
        return x.a>y.a;
}

int main()
{
    ll a,b,c;
    ll f1,f2,f3;
    while(scanf("%d",&n)!=EOF)
    {
        ll MAX=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld%lld%lld",&a,&b,&c);
            ll sum=a+b+c;
            sqr[i].a=max(a,max(b,c));
            sqr[i].c=min(a,min(b,c));
            sqr[i].b=(sum-sqr[i].a-sqr[i].c);
            sqr[i].num=i;
            if(MAX < sqr[i].c)
            {
                f1=i;
                MAX=sqr[i].c;
            }
        }
        sort(sqr+1,sqr+1+n,cmp);

        int flag=0;
        for(int i=1;i<n;i++)
        {
            if(sqr[i].a==sqr[i+1].a&&sqr[i].b==sqr[i+1].b)
            {

                if(MAX<min((sqr[i].c+sqr[i+1].c),sqr[i].b))
                {
                    MAX=min((sqr[i].c+sqr[i+1].c),sqr[i].b);
                    flag=1;
                    f2=sqr[i].num;
                    f3=sqr[i+1].num;

                }
            }
        }
        if(!flag)
        {
            printf("1\n");
            printf("%lld\n",f1);
        }
        else
        {
            printf("2\n");
            printf("%lld %lld\n",f2,f3);
        }
    }return 0;
}

 

codeforces 733D