Average Score


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis.

After a mid-term exam, Bob was anxious about his grade. He went to the professor asking about the result of the exam. The professor said:

"Too bad! You made me so disappointed."

"Hummm... I am giving lessons to two classes. If you were in the other class, the average scores of both classes will increase."

Now, you are given the scores of all students in the two classes, except for the Bob's. Please calculate the possible range of Bob's score. All scores shall be integers within [0, 100].

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains two integers N (2 <= N <= 50) and M (1 <= M <= 50) indicating the number of students in Bob's class and the number of students in the other class respectively.

The next line contains N - 1 integers A1, A2, .., AN-1 representing the scores of other students in Bob's class.

The last line contains M integers B1, B2, .., BM representing the scores of students in the other class.

Output

For each test case, output two integers representing the minimal possible score and the maximal possible score of Bob.

It is guaranteed that the solution always exists.

Sample Input

2
4 3
5 5 5
4 4 3
6 5
5 5 4 5 3
1 3 2 2 1

Sample Output

4 4
2 4

Author: JIANG, Kai
Source: The 2014 ACM-ICPC Asia
Mudanjiang Regional Contest

题意:Bob班里有N个人(加上自己),邻班有M个人。若Bob不在自己的班里,而在邻班里面,两班的平均分都会增加。现在已经给出Bob班里N-1个人的分数以及邻班M个人的分数,问你Bob分数的最小值和最大值。

设Bob分数为x,自己班里除了他之外总分数为suma,邻班总分数为sumb。

显然有sum1/ (N-1) >= x >= sum2 / M + 1。对于sum1 / (N-1)要分能否整除讨论一下。

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j,t,sumb;
double suma;
int x,y,a,b,Max,Min;
scanf("%d",&t);
while(t--)
{
suma=0;sumb=0;
scanf("%d%d",&n,&m);
for(i=0;i<n-1;i++)
{
scanf("%d",&a);
suma+=a;
}
suma=suma/(n-1);
x=(int)(suma);
if(suma>x)
Max=x;
else if(suma==x)
Max=x-1;
for(i=0;i<m;i++)
{
scanf("%d",&b);
sumb+=b;
}
sumb=sumb/m;
Min=sumb+1;
printf("%d %d\n",Min,Max);
}
return 0;
}

  

zoj 3819 Average Score的更多相关文章

  1. ZOJ 3819 Average Score(平均分)

    Description 题目描述 Bob is a freshman in Marjar University. He is clever and diligent. However, he is n ...

  2. ZOJ 3819 Average Score 水

    水 Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar Univer ...

  3. [ACM] ZOJ 3819 Average Score (水题)

    Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...

  4. ZOJ 3819 Average Score(数学 牡丹江游戏网站)

    主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...

  5. ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题

    ZOJ 2819 Average Score Time Limit: 2 Sec  Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...

  6. 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score

    Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...

  7. ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题

    Average Score Time Limit: 2 Seconds      Memory Limit: 131072 KB Bob is a freshman in Marjar Univers ...

  8. 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

    那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score ...

  9. 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...

随机推荐

  1. css3动画使用技巧之—border旋转时的应用。

    <html> <head> <title>css3动画border旋转时的应用.</title> <meta charset="UTF- ...

  2. 2016年1月编程语言排行榜:Java荣获2015年度冠军

    Java因于2015年人气增幅最大(+ 5.94%),故获得2015年的TIOBE指数的编程语言奖,同时成为15年年度冠军, Visual Basic.NET(+ 1.51%)和Python(+ 1. ...

  3. REST API之前端跨域访问

    关键字:跨域访问,cross-origin, NodeJS, REST API, JavaScript, Access-Control-Allow-Origin 1.新建并运行一个 NodeJS的se ...

  4. C#读取Excel几种方法的体会

    (1) OleDb: 用这种方法读取Excel速度还是非常的快的,但这种方式读取数据的时候不太灵活,不过可以在 DataTable 中对数据进行一些删减修改 这种方式将Excel作为一个数据源,直接用 ...

  5. C与OC、C++的区别

    C语言的特点:1)C语言是结构化语言,层次清晰,调试和维护比较容易2)表现能力和处理能力比较强,可直接访问内存的物理地址3)c语言实现对硬件的编辑,c语言课用语系统软件的开发,也可用语应用软件的开发, ...

  6. spirng MVC乱码过滤器

    <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>or ...

  7. 分享七款视差滚动效果的jQuery 插件

    视差(Parallax)是指从不同的点看一个物体时形成的视觉差异,这个名词是源自希腊文的παράλλαξις (parallaxis),意思是”改变”.在网页设计中,视差滚动(Parallax Scr ...

  8. Word添加带圈文字

    这个在项目有编号李没有,只能一个一个输入 A.开始------------字体里选择带圈的字符号 B.插入,符号里选编号

  9. IEEE会议排名(转载)

    不知道谁整理的,我就下了个word.所以就标注不了,引用的哪的了. Rank 1: SIGCOMM: ACM Conf on Comm Architectures, Protocols & A ...

  10. win7 安装SQL Server 2005 开发版 图文教程

    转自win7 安装SQL Server 2005 开发版 图文教程 ----------------------------写在安装前------------------------------ 一. ...