ZOJ 3819 Average Score 水
水
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
#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 水的更多相关文章
- [ACM] ZOJ 3819 Average Score (水题)
Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...
- ZOJ 3819 Average Score(平均分)
Description 题目描述 Bob is a freshman in Marjar University. He is clever and diligent. However, he is n ...
- zoj 3819 Average Score
Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...
- ZOJ 3819 Average Score(数学 牡丹江游戏网站)
主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...
- ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题
ZOJ 2819 Average Score Time Limit: 2 Sec Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...
- 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score
Average Score Time Limit: 2 Seconds Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...
- 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829
那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score ...
- UVa 1585 Score --- 水题
题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...
- ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题
Average Score Time Limit: 2 Seconds Memory Limit: 131072 KB Bob is a freshman in Marjar Univers ...
随机推荐
- leetcode_378. Kth Smallest Element in a Sorted Matrix_堆的应用
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth ...
- laravel学习:模块化caffeinated
# Modules Extract and modularize your code for maintainability. Essentially creates "mini-larav ...
- CAD插入背景图片(网页版)
把图片作为背景图片可见但是不能编辑操作. 主要用到函数说明: _DMxDrawX::DrawImageToBackground 绘光栅图到背景.详细说明如下: 参数 说明 BSTR sFileName ...
- 解决idea开启tomcat报Configuration Error: deployment source 'xxx:war exploded' is not valid错
这个问题比较棘手, 出错了的时候Tomcat服务器不能正常运行, 导致网页无法打开, 小组成员都说"Tomcat炸了"! 好在这个这个xml配置文件是自动生成的,重新生成一下就好了 ...
- JavaSE-18 常用工具类
学习要点 Object类 枚举 包装类 Math类 Random类 字符串处理 日期时间 Object类 1 什么是Object类 Object类存储在java.lang包中,是所有java类(Ob ...
- EasyUI入门,DataGrid(数据表格)
搭建EasyUI 1.进入官网,下载EasyUI的程序包.地址:http://www.jeasyui.com/download/list.php 2.先导入css样式,引入程序包 3.进入EasyUI ...
- notepad++新建文档时,会出现语法错误的红色下波浪线
notepad++新建文档时,会出现语法错误的红色下波浪线: 原因:新建文档时默认设置语言为PHP. 解决方法:修改默认语言为java或JavaScript,如下: 小结:打开文档时,也可能出现下波浪 ...
- 阿里云报错Redirecting to /bin/systemctl restart sshd.service
转:http://blog.csdn.net/caijunfen/article/details/70599138 云服务器 ECS Linux CentOS 7 下重启服务不再通过 service ...
- Linux终端以及bash
目 录 第1章 Linux系统终端概述 1 1.1 图形化 1 1.2 字符终端 1 1.3 who和w 1 1.3.1 who 1 1.3.2 w 1 1.3.3 ...
- thinkphp5 框架修改的地方
框架修改的地方 vendor/topthink/think-captcha/src/Captcha.php api验证码入库 196行 $img_code = strtoupper(implode(' ...