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 ;
}

ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题的更多相关文章

  1. 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

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

  2. ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5381 Information Theory is one of t ...

  3. ZOJ 3819 Average Score(数学 牡丹江游戏网站)

    主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...

  4. 2014ACMICPC亚洲区域赛牡丹江现场赛之旅

    下午就要坐卧铺赶回北京了.闲来无事.写个总结,给以后的自己看. 因为孔神要保研面试,所以仅仅有我们队里三个人上路. 我们是周五坐的十二点出发的卧铺,一路上不算无聊.恰巧邻床是北航的神犇.于是下午和北航 ...

  5. 2014ACM/ICPC亚洲区域赛牡丹江现场赛总结

    不知道怎样说起-- 感觉还没那个比赛的感觉呢?如今就结束了. 9号.10号的时候学校还评比国奖.励志奖啥的,由于要来比赛,所以那些事情队友的国奖不能答辩.自己的励志奖班里乱搞要投票,自己又不在,真是无 ...

  6. zoj 3819 Average Score

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

  7. ZOJ 3819 Average Score 水

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

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

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

  9. 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...

随机推荐

  1. HTTP之一 If-Modified-Since & If-None-Match

    If-Modified-Since & If-None-MatchIf-Modified-Since,和 Last-Modified 一样都是用于记录页面最后修改时间的 HTTP 头信息,只是 ...

  2. Unity3D Instantiate慢的问题

    1.NGUI直接打开界面卡 2.角色放技能的时候卡 3.载入模型的时候卡 http://www.xuanyusong.com/archives/2925

  3. python高性能web框架——Japronto

    近期做了一个简单的demo需求,搭建一个http server,支持简单的qa查询.库中有10000个qa对,需要支持每秒10000次以上的查询请求. 需求比较简单,主要难点就是10000+的RPS. ...

  4. Java代码优化总结

    代码优化是一个很重要的课题.一般来说,代码优化的目标主要有两个,一个是减小代码的体积,另一个是提高代码运行的效率. 代码优化的细节有很多,此处列举部分: 1.尽量指定类.方法的final修饰符. 带有 ...

  5. java基础30 List集合下的LinkedList集合

    单例集合体系: ---------| collection  单例集合的根接口--------------| List  如果实现了list接口的集合类,具备的特点:有序,可重复       注:集合 ...

  6. MySQL通过rpm安装及其单机多实例部署

    1. CentOS 下安装 MySQL Oracle 收购 MySQL 后,CentOS 为避免 MySQL 闭源的风险,改用 MySQL 的分支 MariaDB:MariaDB 完全兼容 MySQL ...

  7. Android Activity、Service、BroadcastReceiver 的生命周期

    Activity.Service.BroadcastReceiver这三个组建是Android开发中最常使用到的组件,在它们的生命周期的各个阶段我们需要针对性的做些事情,了解这些组件的生命周期有利于我 ...

  8. Java第三阶段学习(四、缓冲流)

    一.缓冲流: Java中提供了一套缓冲流,它的存在,可提高IO流的读写速度 缓冲流,根据流的分类分为:字节缓冲流与字符缓冲流. 二.字节缓冲流: 字节缓冲流根据流的方向,共有2个: 1.写入数据到流中 ...

  9. python开发之路Day17-算法设计(冒泡排序、选择排序、插入排序、二叉树)

    s12-20160514-day17 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: ...

  10. java程序员修炼之道——大牛告诉我们应该好好学习与修炼以下知识与技能

    —————————— ASP.Net+Android+IOS开发..Net培训.期待与您交流! —————————— 一:Java语言学习(对线程(thread),串行化,反射,网络编程,JNI技术, ...