现在的位置: 首页 > 综合 > 正文

hdu 4931 Happy Three Friends

2018年04月21日 ⁄ 综合 ⁄ 共 403字 ⁄ 字号 评论关闭

排序  最大俩个数 相加。。剩下最大的三个数相加 判断下就可以了

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int const MAXN = 100;
int const n = 6;
int m[MAXN];
int main(){
    int t;
    while(~scanf("%d",&t)){
        while(t--){
            for(int i = 1;i <= n;i++){
                scanf("%d",&m[i]);
            }
            sort(m+1,m+n+1);
            int s1 = 0,s2 = 0;
            s1 = m[n]+ m[n - 1];
            s2 = m[n-2]+m[n - 3]+m[n-4];
            if(s1 <= s2)printf("What a sad story!\n");
            else printf("Grandpa Shawn is the Winner!\n");
        }
    }
    return 0;
}

抱歉!评论已关闭.