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
题意:有两个班的同学,其中bob在第一班,然后输入每个班同学的成绩,如果bob属于二班的时候,两个班的平均分都会提高,求bob得分的上下限
分析:bob成绩大于二班平均分,小于一班其他的平均分。我用double存总分,在求最后结果时纠结了好久,上限<平均分,如果平均分是整数的话就是-1,不是整数直接强制转换,下限>平均分,不管平均分怎样都直接+1;
其实后来又搜了一下别人写的,发现直接用int就ok,而且还方便,便于求那个平均分是不是整数,直接取模
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int main()
{
int t;
scanf("%d", &t);
for(int k = ; k <= t; k++)
{
int n,m,score;
double scoren = ,scorem = ;
scanf("%d%d", &n, &m);
for(int i = ; i <= n - ; i++)
{
scanf("%d", &score);
scoren += score;
}
for(int i = ; i <= m; i++)
{
scanf("%d", &score);
scorem += score;
}
printf("%d ",(int) ( scorem / m + ) );
if(scoren / (n - ) == (int) scoren / (n - )) //这里一直不确定是不是可行,
printf("%d\n",(int) ( scoren / (n -) - ));
else
printf("%d\n", (int) (scoren / (n - ) ));
} return ;
}

zoj3819Average Score的更多相关文章

  1. Lucene的评分(score)机制研究

    首先,需要学习Lucene的评分计算公式—— 分值计算方式为查询语句q中每个项t与文档d的匹配分值之和,当然还有权重的因素.其中每一项的意思如下表所示: 表3.5 评分公式中的因子 评分因子 描 述 ...

  2. 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

  3. 关于一道数据库例题的解析。为什么σ age>22 (πS_ID,SCORE (SC) ) 选项是错的?

    本人大二学子.近段时间在做数据库复习题的时候遇到一道题,如下. 有关系SC(S_ID,C_ID,AGE,SCORE),查找年龄大于22岁的学生的学号和分数,正确的关系代数表达式是( ) . ⅰ. πS ...

  4. 利用SCORE法则来总结一次偷懒的单元测试过程

    最近遇到一个单元测试的问题,本周正好学个了一个SCORE法则,这里正好练练手应用此法则将问题的前因后果分享给大家. S:背景  代码要有单元测试,检测的标准就是统计代码的单元测试覆盖率,程序员需要达到 ...

  5. Hiho coder 1236 2015 北京网络赛 Score

    五维偏序..一开始被吓到了,后来知道了一种BITSET分块的方法,感觉非常不错. 呆马: #include <iostream> #include <cstdio> #incl ...

  6. Java-集合-第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum 表示学生的班号,例如“class05”。 有如下List List list = new ArrayList(); l

    第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; ...

  7. 第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum 表示学生的班号,例如“class05”。 有如下List List list = new ArrayList();

    list.add(new Student("Tom", 18, 100, "class05")); list.add(new Student("Jer ...

  8. Competition-based User Expertise Score Estimation-20160520

    1.Information publication:sigir 2011 author:Jing Liu Harbin Institute of TechnologyMicrosoft Researc ...

  9. linux 终端报错 Out of memory: Kill process[PID] [process name] score问题分析

    从Out of memory来看是内存超出了,后面的 Kill process[PID] [process name] score好像和进程有关了,下面我们就一起来看看linux 终端报错 Out o ...

随机推荐

  1. Jsp页显示时间标签JSTL标签 <fmt:formatDate/> 实例大全

    <fmt:formatDate value="${isoDate}" type="both"/>2004-5-31 23:59:59 <fmt ...

  2. Javascript 中的 in, hasOwnProperty, delete, for/in

    in 运算符 判断对象是否拥有某一属性只要对象拥有该属性,就会返回true,否则false var point = { x:1, y:1 };alert( 'x' in point );  //tru ...

  3. 022医疗项目-模块二:药品目录的导入导出-对XSSF导出excel类进行封装

    资源全部来源于传智播客. 好的架构师写的程序,就算给刚入门的新手看,新手一看就知道怎么去用.所以我们要对XSSF导出excel类进行封装.这是架构师的工作,但我们也要知道. 我们写一个封装类: 这个类 ...

  4. 第二章 时间控件(DateTime Picker)

    这家伙太懒了,碰到问题才写博文,嘿嘿. 好了进入正题,二话不说,先放地址: 中文:http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm ...

  5. linux64需要增加的依赖库

    sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl zlib1g-dev gcc-multi ...

  6. R 语言实现牛顿下降法

    凸是一个很好的性质.如果已经证明了某个问题是凸的,那这个问题基本上算是解决了. 最近在解决一个多目标优化的问题.多目标的问题往往是非凸的.好在能够知道这个问题的近似解大概是多少.这样这个多目标优化的问 ...

  7. GeoServer 常见问题总结

    Geoserver安装环境 Geoserver在部署发布服务时,经常会遇到如下问题,现总结如下: 1.忘记了GeoServer Web Admin Page的登陆用户名和密码怎么办? 存储位置:C:\ ...

  8. gunzip 和 unzip 解压文件到指定的目录

    Linux 常用的压缩命令有 gzip 和 zip,两种压缩包的结尾不同:zip 压缩的后文件是 *.zip ,而 gzip 压缩后的文件 *.gz  相应的解压缩命令则是 gunzip 和 unzi ...

  9. 执行mount命令时找不到介质或者mount:no medium found的解决办法

    使用vmware时,在虚拟机设置里,设置CD/DVD为系统镜像,挂载时,有时会有找不到介质或者no medium found之类的提示. 根本原因是iso镜像并没有加载到虚拟机系统内. 解决办法: 首 ...

  10. SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)

    使用 SSM ( Spring . SpringMVC 和 Mybatis )已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没 ...