http://acm.hdu.edu.cn/showproblem.php?pid=4974

话说是签到题,我也不懂什么是签到题。

A simple water problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 196    Accepted Submission(s):
124

Problem Description
Dragon is watching competitions on TV. Every
competition is held between two competitors, and surely Dragon's favorite. After
each competition he will give a score of either 0 or 1 for each competitor and
add it to the total score of that competitor. The total score begins with zero.
Here's an example: four competitors with name James, Victoria, Penghu, and Digo.
First goes a competition between Penghu and Digo, and Dragon enjoys the
competition and draw both 1 score for them. Then there’s a competition between
James and Victoria, but this time Dragon draw 1 for Victoria and 0 for James.
Lastly a competition between James and Digo is held, but this time Dragon really
dislike the competition and give zeroes for each of them. Finally we know the
score for each one: James--0, Victoria--1, Penghu--1, Digo--1. All except James
are the Winner!

However, Dragon's mom comes back home again and close the
TV, driving Dragon to his homework, and find out the paper with scores of all
competitors. Dragon's mom wants to know how many competition Dragon watched, but
it's hard through the paper. Here comes the problem for you, given the scores of
all competitors, at least how many competitions had Dragon watched?

 
Input
The first line of input contains only one integer
T(<=10), the number of test cases. Following T blocks, each block describe
one test case.

For each test case, the first line contains only one
integers N(<=100000), which means the number of competitors. Then a line
contains N integers
(a1,a2,a3,...,an).ai(<=1000000)
means the score of i-th competitor.

 
Output
Each output should occupy one line. Each line should
start with "Case #i: ", with i implying the case number. Then for each case just
puts a line with one integer, implying the competition at least should be
watched by dragon.
 
Sample Input
1
3
2 3 4
 
Sample Output
Case #1: 5
 
Source
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a[];
int main()
{
int n,t,k=,i,sum,mmax;
scanf("%d",&t);
while(t--)
{
sum=mmax=;
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
if(mmax<a[i])
mmax=a[i];
}
int ans=max((sum+)/,mmax);
printf("Case #%d: %d\n",k++,ans);
}
return ;
}

HDU-4974 A simple water problem的更多相关文章

  1. HDU 4974 A simple water problem(贪心)

    HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 ...

  2. hdu - 4974 - A simple water problem(贪心 + 反证)

    题意:N个队(N <= 100000),每一个队有个总分ai(ai <= 1000000),每场比赛比赛两方最多各可获得1分,问最少经过了多少场比赛. 题目链接:http://acm.hd ...

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

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

  4. HDOJ 4974 A simple water problem

    A simple water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  5. HDU 4978 A simple probability problem

    A simple probability problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  6. HDU 1757 A Simple Math Problem 【矩阵经典7 构造矩阵递推式】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (J ...

  7. hdu 1757 A Simple Math Problem (乘法矩阵)

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. HDU 1757 A Simple Math Problem (矩阵快速幂)

    题目 A Simple Math Problem 解析 矩阵快速幂模板题 构造矩阵 \[\begin{bmatrix}a_0&a_1&a_2&a_3&a_4&a ...

  9. HDU 1757 A Simple Math Problem(矩阵)

    A Simple Math Problem [题目链接]A Simple Math Problem [题目类型]矩阵快速幂 &题解: 这是一个模板题,也算是入门了吧. 推荐一个博客:点这里 跟 ...

随机推荐

  1. mysql连接错误:Cannot get hostname for your address

    问题 环境:win7 + 64Bit + 本地mysql5.6 问题:navicat连接本地mysql数据库,提示“Cannot get hostname for your address”,但是连接 ...

  2. vs2015中ctrl+shift+F进行“在文件中查找”,有时候无效?

    搜狗拼音的默认简繁切换快捷键是ctrl+shift+F,改掉以后vs就可以收到这个按键消息了

  3. js关闭窗口

    window.close() window.open("about:blank","_self").close() window.open("&quo ...

  4. [XML] C# XmlHelper操作Xml文档的帮助类 (转载)

    点击下载 XmlHelper.rar 主要功能如下所示 /// <summary> /// 类说明:XmlHelper /// 编 码 人:苏飞 /// 联系方式:361983679 // ...

  5. FragmentTransaction.addToBackStack无效的问题

    FragmentTransaction.addToBackStack无效的问题: 如果当前的类继承的ActionBarActivity,则FragmentManager必须来自v4包,这样addToB ...

  6. org.hibernate.HibernateException: No CurrentSessionContext configured!

    hibernate可以通过两种方式获得Session: getCurrentSession() 和openSession(). 当通过getCurrentSession()方法时,需要在 hibern ...

  7. C# - linq查询现有的DataTable

    可以通过linq对现有的DataTable进行查询,并将结果拷贝至新的DataTable中例如: // Query the SalesOrderHeader table for orders plac ...

  8. Java23种设计模式之单例模式

    一.单例模式简介 单例模式是Java设计模式中常见的一种模式.主要分为懒汉式单例.饿汉式单例.登记式单例: 单例模式的特点:  1.单例类只能有一个实例:  2.单例类必须自己创建自己的唯一的实例: ...

  9. [HttpException (0x80004005): Failed to Execute URL.]之画蛇添足之痛

    最近很悲惨,发布的一个mvc站点,所有的静态内容,如js.css.图片都不能正常加载,服务器给出的响应是一个如下的异常黄页: Server Error in '/ua' Application.Fai ...

  10. C++专题 - Qt是什么

    Qt是一个1991年由奇趣科技开发的跨平台C++图形用户界面应用程序开发框架.它既可以开发GUI程式,也可用于开发非GUI程式,比如控制台工具和服务器.Qt是面向对象的框架,使用特殊的代码生成扩展(称 ...