HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)
Problem Description
The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.
One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one contestant to another, because judges with any relationship whatsoever with a specific contestant are temporarily excluded for scoring his/her performance.
Basically, scores given to a contestant’s performance by the judges are averaged to decide his/her score. To avoid letting judges with eccentric viewpoints too much influence the score, the highest and the lowest scores are set aside in this calculation. If the same highest score is marked by two or more judges, only one of them is ignored. The same is with the lowest score. The average, which may contain fractions, are truncated down to obtain final score as an integer.
You are asked to write a program that computes the scores of performances, given the scores of all the judges, to speed up the event to be suited for a TV program.
Input
The input consists of a number of datasets, each corresponding to a contestant’s performance. There are no more than 20 datasets in the input.
A dataset begins with a line with an integer n, the number of judges participated in scoring the performance (3 ≤ n ≤ 100). Each of the n lines following it has an integral score s (0 ≤ s ≤ 1000) marked by a judge. No other characters except for digits to express these numbers are in the input. Judges’ names are kept secret.
The end of the input is indicated by a line with a single zero in it.
Output
For each dataset, a line containing a single decimal integer indicating the score for the corresponding performance should be output. No other characters should be on the output line.
Sample Input
3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
402
274
283
132
402
523
0
Sample Output
342
7
300
326
分数都是整数!平均分也要是整数!
评委打分,去掉一个最高分,去掉一个最低分,求剩下的平均分!
不用四舍五入。直接舍去小数位就可以。
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
if(n<=0){
return ;
}
int sum =0;
int min = sc.nextInt();
int max=min;
sum=max;
int b;
for(int i=1;i<n;i++){
b = sc.nextInt();
if(b>max){
max=b;
}
if(b<min){
min=b;
}
sum+=b;
}
sum=sum-min-max;
System.out.println((int)(sum/(n-2)));
}
}
}
HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)的更多相关文章
- hdu2309ICPC Score Totalizer Software
Problem Description The International Clown and Pierrot Competition (ICPC), is one of the most disti ...
- HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)
HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...
- HDOJ(HDU).2660 Accepted Necklace (DFS)
HDOJ(HDU).2660 Accepted Necklace (DFS) 点我挑战题目 题意分析 给出一些石头,这些石头都有自身的价值和重量.现在要求从这些石头中选K个石头,求出重量不超过W的这些 ...
- HDOJ(HDU).1003 Max Sum (DP)
HDOJ(HDU).1003 Max Sum (DP) 点我挑战题目 算法学习-–动态规划初探 题意分析 给出一段数字序列,求出最大连续子段和.典型的动态规划问题. 用数组a表示存储的数字序列,sum ...
- HDOJ(HDU).1045 Fire Net (DFS)
HDOJ(HDU).1045 Fire Net [从零开始DFS(7)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HD ...
- HDOJ(HDU).1241 Oil Deposits(DFS)
HDOJ(HDU).1241 Oil Deposits(DFS) [从零开始DFS(5)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架 ...
- HDOJ(HDU).1035 Robot Motion (DFS)
HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...
- HDOJ(HDU).1412 {A} + {B} (STL SET)
HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...
- HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)
HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...
随机推荐
- JS cookie 读写操作
/*** ** 功能: cookie操作对象 ***/ var cookies = { /*** ** 功能: 写入cookie操作 ** 参数: name cookie名称 ** value coo ...
- Sql server 数据库中,纯SQL语句查询、执行 单引号问题。
在默认值情况下, select 'abc',Titile from tb_Name; ---输出内容 是abc: 如果想输出 单引号 'abc,需要使用select '''abc',Titile f ...
- metalink下载补丁包
以下截图 截取自 某 升级包中携带的 readme文档 把以上图片转换为 文字 Download and Install Patch Updates Refer to the My Oracle Su ...
- 移动触摸事件(touchstart、touchmove和touchend)
touchstart事件:当手指触摸屏幕时候触发,即使已经有一个手指放在屏幕上也会触发. touchmove事件:当手指在屏幕上滑动的时候连续地触发.在这个事件发生期间,调用preventDefaul ...
- 使用Physics_Body_Editor获得json文件的类
[转自]:http://www.cocoachina.com/bbs/read.php?tid=209290 工具介绍,json文件获得方法,请参考原帖 MyBodyParser.h // // My ...
- 虚拟机VHD格式解析到NTFS文件系统解析
本来的需求是XEN下的镜像取证,但这篇仅包括他支持的一种格式,就是VHD,此项目从头开始大概用了两周时间,中间遇到了很多让人头大的问题,光是思考的笔记就写了十几页纸,不过实际上并没有那么难,主要是很久 ...
- js 之 复制一段代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 《du命令》-linux命令五分钟系列之三
本原创文章属于<Linux大棚>博客. 博客地址为http://roclinux.cn. 文章作者为roc 希望您能通过捐款的方式支持Linux大棚博客的运行和发展.请见“关于捐款” == ...
- php学习代码杂记
16/2/22 字符串连接 (1)连接运算符(“.”):它返回将右参数附加到左参数后面所得的字符串. (2)连接赋值运算符(“.=”):它将右边参数附加到左边的参数后. 相当于JS里面的 += . $ ...
- php基础知识【函数】(3)字符串string
一.大小写转换 1.strtolower()--转换为小写. echo strtolower("Hello WORLD!"); //hello world! 2.strtouppe ...