ZOJ 2819 Average Score

Time Limit: 2 Sec  Memory Limit: 60 MB

题目连接

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

Description

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

HINT

题意给你两个班级,告诉你把bob扔到B班去,两个班级的平均分都会上升,然后问你,bob的分数上下限是多少

题解:

暴力枚举平均分,然后显然bob只要比第一个班级的平均分低,比第二个班级的平均分高就行了

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* */
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int main()
{
int t;
t=read();
while(t--)
{
int n,m;
n=read(),m=read();
int ans1=,ans2=;
for(int i=;i<n-;i++)
{
int x=read();
ans1+=x;
}
for(int i=;i<m;i++)
{
int x=read();
ans2+=x;
}
int t1=,t2=;
while(t1*m<=ans2)
t1++;
while(t2*(n-)<ans1)
t2++;
printf("%d %d\n",t1,t2-);
}
return ;
}

最新文章

  1. 不会JavaScript能混前端么?能拿到高薪么?
  2. js浏览器对象的属性和方法
  3. The import java.io cannot be resolved
  4. SQL Server排序函数row_number和rank的区别
  5. FastReport 隐藏matrix的列如何实现
  6. 【原】iOS学习39网络之数据请求
  7. animation of android (1)
  8. hive创建表带中文注释报错解决方法
  9. 乐酷工作室孙志伟:Testin云測试有广度有深度 省钱省力值得信赖
  10. 201521123049 《JAVA程序设计》 第10周学习总结
  11. BeautifulSoup模块过滤掉html标签,只拿文本内容(处理XSS攻击)
  12. vscode 集成 cygwin 的注意事项
  13. Leetcode——413. 等差数列划分
  14. cocos2dx 3.1.1移植安卓apk (lua项目交叉编译 mac环境下)
  15. python3中SSLError错误处理
  16. 使用Bootstrap 3开发响应式网站实践04,使用Panels展示内容
  17. mysql数据库要按当天、昨天、前七日、近三十天、季度、年查询
  18. [转]JSONObject,JSONArray使用手册
  19. 你以为border-radius只是圆角吗?【各种角度】
  20. ①SpringCloud前序知识-CAP原则

热门文章

  1. Linux内核跟踪之ring buffer的实现【转】
  2. win7 64位mysql安装及navicat 解压版
  3. CSS3小黄人
  4. JavaScript 中的回调函数
  5. nginx重写链接
  6. SQLSERVER 2008 编辑所有或者任意行
  7. 2016-2017-2 20155309南皓芯《java程序设计》第十周学习总结
  8. 学习python绘图
  9. C# 在RichTextBox根据内容自动调整高度
  10. Rookey.Frame之数据库及缓存配置