hdu 4931 Happy Three Friends(水题)

题目链接:hdu 4931 Happy Three Friends

题目大意:题意很好懂,而且貌似也不会有人来看这种水题的题解。

解题思路:本来这种水题是不想写题解的,但是既然做了就留下痕迹吧~

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main () {
    int cas;
    scanf("%d", &cas);
    while (cas--) {
        int sum = 0, arr[10];
        for (int i = 0; i < 6; i++) {
            scanf("%d", &arr[i]);
            sum += arr[i];
        }
        sort (arr, arr + 6);
        int ans = arr[5] + arr[4];
        sum -= (ans + arr[0]);
        printf("%s\n", ans > sum ? "Grandpa Shawn is the Winner!" : "What a sad story!");
    }
    return 0;
}

你可能感兴趣的:(hdu 4931 Happy Three Friends(水题))