码迷,mamicode.com
首页 > 其他好文 > 详细

2014多校第十场1004 || HDU 4974 A simple water problem

时间:2014-08-21 22:37:24      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   

题目链接

题意 : n支队伍,每场两个队伍表演,有可能两个队伍都得一分,也可能其中一个队伍一分,也可能都是0分,每个队伍将参加的场次得到的分数加起来,给你每个队伍最终得分,让你计算至少表演了几场。

思路 : ans = max(maxx,(sum+1)/2) ;其实想想就可以,如果所有得分中最大值没有和的一半大,那就是队伍中一半一半对打,否则的话最大的那个就都包了。

bubuko.com,布布扣
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <stdlib.h>
 4 #include <iostream>
 5 
 6 using namespace std ;
 7 
 8 int a[101010] ;
 9 
10 int main()
11 {
12     int n ,maxx,sum ;
13     int T ,casee = 1;
14     //freopen("1004.in","r",stdin) ;
15     scanf("%d",&T) ;
16     while(T --)
17     {
18         scanf("%d",&n) ;
19         maxx = -1 ;sum = 0 ;
20         for(int i = 0 ; i < n ; i++)
21         {
22             scanf("%d",&a[i]) ;
23             maxx = max(a[i],maxx) ;
24             sum += a[i] ;
25         }
26         printf("Case #%d: %d\n",casee++ ,max(maxx,(sum + 1)/ 2)) ;
27     }
28     return 0 ;
29 }
View Code

 

2014多校第十场1004 || HDU 4974 A simple water problem,布布扣,bubuko.com

2014多校第十场1004 || HDU 4974 A simple water problem

标签:style   blog   http   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/luyingfeng/p/3928119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!