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. iTOP-4418/6818开发板支持双屏异显,双屏同显

    iTOP-4418/6818开发板平台安卓系统下支持双屏异显,双屏同显,客户可按照不同用途,分别播放适合屏幕显示方式的内容 ,如HDMI屏幕和LCD屏幕显示不同内容, 一个屏幕播放广告,另一个屏幕运行 ...

  2. 迅为八核cortex a53开发板android/linux/Ubuntu系统

    详情请点击了解:http://www.topeetobard.com 店铺:https://arm-board.taobao.com 核心板: 提供1G和2G内存版本,全机器焊接,杜绝手工,批量无忧. ...

  3. php简单实用的调试工具类

    <?php /* * 调试类 */ class Common_Debug { //打开错误报告 public static function showError($debug = true) { ...

  4. Spring MVC全局异常后返回JSON异常数据

    问题: 当前项目是作为手机APP后台支持,使用spring mvc + mybaits + shiro进行开发.后台服务与手机端交互是发送JSON数据.如果后台发生异常,会直接返回异常页面,显示异常内 ...

  5. python 调用exe程序

    #!/usr/bin/python #-*- coding:utf-8 -*- import os, subprocess import tkMessageBox import msg_box def ...

  6. vue mixins应用场景

    学习知识得在应用场景中去应用,这样才能真正学到东西,记忆也深刻,以后碰到类似的东西就会了. 1.在assets文件夹下创建一个js文件 // 创建一个需要混入的对象 export const mixi ...

  7. Python 迭代器-生成器-面向过程编程

    上节课复习:1. 函数的递归调用 在调用一个函数的过程中又直接或者间接地调用了函数本身称之为函数的递归 函数的递归调用有两个明确的阶段: 1. 回溯 一层一层地调用本身 注意: 1.每一次调用问题的规 ...

  8. PHPExcel读取表格内容

    PHPExcel读取表格 先引入类IOFactory.php require_once '../PHPExcel/IOFactory.php'; $filePath = "test.xlsx ...

  9. 13Spring通过注解配置Bean(1)

    配置Bean的形式:基于XML文件的方式:基于注解的方式(基于注解配置Bean:基于注解来装配Bean的属性) 下面介绍基于注解的方式来配置Bean. ——组件扫描(component scannin ...

  10. 安装nvm 切换nodejs版本

    删除已安装的nodejs--------------------------------------------------------------- #查看已经安装在全局的模块,以便删除这些全局模块 ...