主题链接:

problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373

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

PS:2014年ACM/ICPC 亚洲区域赛牡丹江(第一站)___签到题!

代码例如以下:

#include <cstdio>
#include <cmath>
int main()
{ int t;
int n, m;
int minn, maxx;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
double sum1=0, sum2=0;
int a;
for(int i = 0; i < n-1; i++)
{
scanf("%d",&a);
sum1+=a;
}
for(int i = 0; i < m; i++)
{
scanf("%d",&a);
sum2+=a;
}
double avg1=(sum1/(n-1.0));
double avg2=sum2/(m*1.0);
if((int)avg1==avg1)
maxx=(int)avg1-1;
else
maxx=(int)avg1;
minn=(int)avg2+1;
printf("%d %d\n",minn,maxx);
}
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 Universi ...

  3. ZOJ 3819 Average Score 水

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

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

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

  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. 基于jQuery游戏网站焦点图轮播特效

    基于jQuery的一款游戏网站焦点图轮播特效.这是一款带进度条定时切换,带缩略图切换的jQuery网站焦点图代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <cente ...

随机推荐

  1. 自行实现透明的控件如Panel GroupBox(使用不需要重绘父控件的效果,一切都因为窗口有了WS_EX_TRANSPARENT属性)

    CSDN的Blog开通了.我想这里的Blog作为今后自己回答别人问题的时候,收藏答案的地方很不错呢. 因为社区的贴子早晚都会沉下去,查找起来很不方便,甚至再也找不到呢. Q: http://commu ...

  2. css3-6 表格如何设置样式和定位样式是什么

    css3-6 表格如何设置样式和定位样式是什么 一.总结 一句话总结:css可以解决所有属性设置的样式. 1.表格如何设置样式? css样式可以解决一切问题,没必要在表格上面加属性来设置样式. 7 t ...

  3. php javascript的ajax

    先说基础一点的get类型的ajax function loadXMLDoc() { var xmlhttp;//首先判断浏览器是否支持xmlhttprequest,因为ie56不是这个对象,是acti ...

  4. 【40.17%】【codeforces 569B】Inventory

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 上传文件是常要处理的事情,使用ajaxFileUpload.js处理比较方便,这里的ajaxFileUpload.js文件修改过的,

    上传文件是常要处理的事情,使用ajaxFileUpload.js处理比较方便,这里的ajaxFileUpload.js文件修改过的, Html部分 <input type="file& ...

  6. Java中String推断相等equals与==的差别以及StringBuilder的equals

    Java中String类型具有一个equals的方法能够用于推断两种字符串是否相等,可是这样的相等又与运算符==所推断的"相等"有所不同,接下来进行分析,结论由程序进行验证 Str ...

  7. Centos6.5 VNC 配置

    VNC 配置 本教程配置说明 目的:实现Window下VNC登陆Linux服务器 本机是在root用户下操作完毕 两台主机已实现基本网络配置,且相互ping通 1. 检查图形界面 确保服务器端须要执行 ...

  8. C#生成、解析xml文件以及处理报错原因

    转载自:http://blog.csdn.net/lilinoscar/article/details/21027319 简单的介绍一下生成XML文件以及解析,因为有些数据不一定放到数据库,减少链接数 ...

  9. js进阶 11-12 jquery如何实现节点的删除和复制

    js进阶 11-12  jquery如何实现节点的删除和复制 一.总结 一句话总结:remove().detach().empty()方法 1.jquery删除节点中的remove()方法和detac ...

  10. 自旋锁解决StackOverflowError案例

    本节笔者分享一个在实际工作中遇到的栈内存溢出(StackOverflowError)问题,以及其解决方案. 问题介绍:笔者负责的一个Java Web项目在启动的时候,需要有一些初始化操作,而接下来的代 ...