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. jquery 提示信息显示后自动消失的具体实现

    方法一: 复制代码 代码如下: $("#errormsg").html("您的信息输入错误,请重试!").show(300).delay(3000).hide( ...

  2. jsoup:解析HTML用法小结

    1.解析方式 (1)从字符串解析 ? 1 2 3 String html = "<html><head><title>First parse</ti ...

  3. python文件操作汇总

    1.创建文件 f = open(filename,'w+')

  4. CSS 创建

    当读到一个样式表时,浏览器会根据它来格式化 HTML 文档. 如何插入样式表 插入样式表的方法有三种: 外部样式表 内部样式表 内联样式 外部样式表 当样式需要应用于很多页面时,外部样式表将是理想的选 ...

  5. Js浏览器对象

    Js浏览器对象——window对象 1.window对象: (1)window对象是BOM的核心,window对象指当前的浏览器窗口. (2)所有的JavaScript全局对象.函数以及变量均自动成为 ...

  6. ZOJ 1733 Common Subsequence(LCS)

    Common Subsequence Time Limit: 2 Seconds      Memory Limit: 65536 KB A subsequence of a given sequen ...

  7. 创业 CEO:如何选择投资人

    欢迎来到「创业 CEO」系列,在这个系列中,我们讨论一个创业者如何教会自己成为一位伟大的 CEO,因为历史上最伟大的创业公司,往往都是由这样的人在领导. AppWorks 成立至今,总共参与投资了 2 ...

  8. 如何给html元素的onclick事件传递参数(即如何获取html标签的data-*属性)

    现在做的一个小系统为了达到领导所说的很炫的效果有用到Metro UI CSS,但是因为如何给每个磁贴(div标签)的click事件传递参数折腾了蛮久(偶是菜鸟),后来终于找到一个解决方案即通过data ...

  9. php的各种配置

    问题:1.如果去掉URL_MODEL=1时的index.php第一步:把Apache配置文件中的LoadModule rewrite_module modules/mod_rewrite.so 取消注 ...

  10. 分享一个自己写的基于TP的关系模型(四)

    修复分页BUG,原有代码查询到最后一页就一只查询最后一页 $ ? $; $this->maxPage = ceil($this->total/$this->rows); //$thi ...