题意:按一定规则排序后,是否能够使头尾两个数之和大于其他数中任选3个数的和
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4931
思路:排序,对该数组中最大的两数之和与第三、四、五个数的和比较即可。
注意点:无。
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12479785 | 2014-12-12 19:54:06 | Accepted | 4931 | 15MS | 1192K | 1250 B | G++ | 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;
}