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 A1A2, .., AN-1 representing the scores of other students in Bob's
class.

The last line contains M integers B1B2, .., 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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int INF=0x3f3f3f3f; int n,m;
int suma,sumb; int main()
{
int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d%d",&n,&m);
suma=sumb=0;
for(int i=0;i<n-1;i++)
{
int x;
scanf("%d",&x);
suma+=x;
}
for(int i=0;i<m;i++)
{
int x;
scanf("%d",&x);
sumb+=x;
}
int MIN=INF,MAX=-INF;
for(int i=0;i<=100;i++)
{
if((suma*n>(suma+i)*(n-1))&&(sumb*(m+1)<(sumb+i)*m))
{
MIN=min(MIN,i);
MAX=max(MAX,i);
}
}
printf("%d %d\n",MIN,MAX);
}
return 0;
}

ZOJ 3819 Average Score 水的更多相关文章

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

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

  2. ZOJ 3819 Average Score(平均分)

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

  3. 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. 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

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

  8. UVa 1585 Score --- 水题

    题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...

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

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

随机推荐

  1. Laravel Passport认证-多表、多字段解决方案

    Laravel Passport认证-多表.多字段解决方案 2018年08月19日 09:31:01 醉卧码场君莫笑 阅读数:1632   1. 概述 API 通常使用令牌(token)进行认证并且在 ...

  2. 《Java程序设计》课程试题

    < Java程序设计 >课程试题 一.单项选择题(20题:每题2分,共40分) 1.若数组a定义为int[][]a=new int[3][4],则a是___. A)一维数组 B)二维数组 ...

  3. sql server使用的注意点及优化点 自备

    1.字符类型建议采用varchar/nvarchar数据类型,并且禁止使用varchar(max).nvarchar(max) 2.金额货币建议采用money数据类型  (*) 3.自增长标识建议采用 ...

  4. linux下的文档处理及tar命令

    1.使用cat命令进行纵向合并 使用‘>’是将左边的内容覆盖到右边 使用‘>>’是将左边的内容追加到右边文档中 还可使用‘>’将不同文件进行合并 2.管道符‘|’统计行数 使用 ...

  5. 杭电 2124 Repair the Wall(贪心)

    Description Long time ago , Kitty lived in a small village. The air was fresh and the scenery was ve ...

  6. 3W法则-学习Docker

    一.前言       5W1H法则是在一次面试中学习到的,后来在工作也开始使用这种东西,虽然最后没去那家公司,但是也是学习到了,关注开这些东西以后,也发现了一些简化版的3W法则,最近公司也要搞Doce ...

  7. Directory获取方式

    1) FSDirectory.open FSDirectory.open()会以最合适的方式来获取一个Directory对象. 2) RAMDirectory 可以将磁盘中的索引加载到内存中,访问速度 ...

  8. 04001_HTML简单介绍

    1.超文本标记语言 (1)超文本:比普通文本功能更加强大: (2)标记语言:使用一组标签对内容进行描述的一门语言,它不是编程语言! 2.HTML语法和规范 (1)所有的html文件后缀名都是以.htm ...

  9. 如何抓取崩溃的log日志

    4.手机录屏工具的推荐 Andriod:录屏大师,易录屏等等. iOS:AirPlayer,iTools. 5.如何抓取崩溃的log日志? android闪退获取日志方法: 1.下载adb工具包 2. ...

  10. eclipse中自动生成注释

    eclipse中自动生成注释 包前缀设置的地方 注释模板设置的地方 Eclipse自动生成方法注释 快捷键 自动生成方法的注释格式,例如 /*** @param str* @return* @thro ...