HDOJ 4931 Happy Three Friends

66 篇文章 0 订阅
20 篇文章 0 订阅

题意:按一定规则排序后,是否能够使头尾两个数之和大于其他数中任选3个数的和

链接:http://acm.hdu.edu.cn/showproblem.php?pid=4931

思路:排序,对该数组中最大的两数之和与第三、四、五个数的和比较即可。

注意点:无。


以下为AC代码:

Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor
124797852014-12-12 19:54:06Accepted493115MS1192K1250 BG++luminous11
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;

int num[10];

bool calc ()
{
    int a = num[1] + num[2] + num[3];
    int b = num[4] + num[5];
    if ( a >= b )
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int t;
    cin >> t;
    while ( t -- )
    {
        for ( int i = 0; i < 6; i ++ )
        {
            scanf ( "%d", &num[i] );
        }
        sort ( num, num + 6 );
        if ( calc () )
        {
            printf ( "What a sad story!\n" );
        }
        else
        {
            printf ( "Grandpa Shawn is the Winner!\n" );
        }
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值