zoj3819Average 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 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 = 1; k <= t; k++)
    {
        int n,m,score;
        double scoren = 0,scorem = 0;
        scanf("%d%d", &n, &m);
        for(int i = 1; i <= n - 1; i++)
        {
            scanf("%d", &score);
            scoren += score;
        }
        for(int i = 1; i <= m; i++)
        {
            scanf("%d", &score);
            scorem += score;
        }
        printf("%d ",(int) ( scorem / m + 1) );
        if(scoren / (n - 1) == (int) scoren / (n - 1))  //这里一直不确定是不是可行,
        printf("%d\n",(int) ( scoren / (n -1) - 1));
        else
            printf("%d\n", (int) (scoren / (n - 1) ));
    }

    return 0;
}
时间: 2024-10-06 08:08:32

zoj3819Average Score的相关文章

设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示。用SQL语句创建四个表并完成相关题目。

表(一)Student (学生表) -- Create table create table STUDENT ( sno VARCHAR2(3) not null, sname VARCHAR2(8) not null, ssex VARCHAR2(2) not null, sbirthday DATE, class VARCHAR2(5) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255; -- Add comments to the

机器学习中的 precision、recall、accuracy、F1 Score

1. 四个概念定义:TP.FP.TN.FN 先看四个概念定义: - TP,True Positive - FP,False Positive - TN,True Negative - FN,False Negative 如何理解记忆这四个概念定义呢? 举个简单的二元分类问题 例子: 假设,我们要对某一封邮件做出一个判定,判定这封邮件是垃圾邮件.还是这封邮件不是垃圾邮件? 如果判定是垃圾邮件,那就是做出(Positive)的判定: 如果判定不是垃圾邮件,那就做出(Negative)的判定. Tru

sitecore+score 在 Experience editor 添加新元素时associateed content 指向错误

Q:在sitecore的Experience editor页面添加component时,子元素的路径指向错误.如图: A: 首先你要整理思路,这个设置可能是在哪,是template还是control layout.当然这里肯定是跟页面control有关. 1.我们需要找到这个button的control layout.因为我们的项目是集成了score,所以根据score的手册我们知道这个button的路径在/sitecore/layout/Renderings/BootstrapUI/Conte

out of memory kill process (java) score or a child

最近在跑大数据,发现 out of memory kill process (java) score or a child,查资料发现是操作系统linux low mem 太低,后来加大内存一样不管用,开始分析代码: 将代码中的String 字符串拼接改成StringBuilder(单线程速度比StringBuffer快) 将获取文件名称的方法file.listFiles() 改成 file.list() 将代码中的不必要的创建对象.数组开销去掉,尤其是在循环里 发现仍然有问题,通过free -

查询score中选学多门课程的同学中分数为非最高分成绩的记录。

20.查询score中选学多门课程的同学中分数为非最高分成绩的记录. select * from score a where sno in ( select sno from score group by sno having count(1)>1) and a.degree<(select max(degree) from score b where a.cno=b.cno  )

ZOJ 3819 Average Score(平均分)

[题目描述] English 中文 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 t

2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( 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

python 函数进阶class Student(object): @property def score(self): return self._score @score.setter def score(self, value): if not isinstance(value, int): raise V

1.类和实例 #类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的"对象",每个对象都拥有相同的方法,但各自的数据可能不同. #__init__ 方法 ,其第一个参数永远是self,print_score也是方法. name score 属性 class Student(object): def __init__(self, name, score):        self.name = name        self.score = score def p

第三题 有如下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(“Jerry”, 22, 70, “class04”)); list.add(new Student(“Owen”, 25, 90, “class05”)); list.add(new Student(“Jim”, 30,80 , “class05”)); list.add(new Student(“Steve”, 28, 66, “class06”));