题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4931
3 1 2 3 3 2 2 2 2 2 2 2 2 1 2 2 2 3 4
What a sad story! What a sad story! Grandpa Shawn is the Winner!HintFor the first test case , {3 , 1 , 2 , 2 , 2 , 3} Grandpa Shawn can take 6 at most . But Beautiful-leg Mzry can take 6 too. So there is a tie. For the second test cases , Grandpa Shawn loses. For the last one , Dong-hao can arrange the numbers as {3 , 2 , 2 , 2 , 1 , 4} , Grandpa Shawn can take 7 , but Beautiful-leg Mzry can take 6 at most. So Grandpa Shawn Wins!
代码如下:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
int a[6];
while(~scanf("%d",&t))
{
while(t--)
{
for(int i = 0; i < 6; i++)
{
scanf("%d",&a[i]);
}
sort(a,a+6);
if(a[5]+a[4] > a[3]+a[2]+a[1])
{
printf("Grandpa Shawn is the Winner!\n");
}
else
printf("What a sad story!\n");
}
}
return 0;
}
hdu4931 Happy Three Friends(BestCoder Round#4签到题),布布扣,bubuko.com
hdu4931 Happy Three Friends(BestCoder Round#4签到题)
原文地址:http://blog.csdn.net/u012860063/article/details/38492945