ZOJ 2819 Average score mudanjiang field game a water problem/registration question

Source: Internet
Author: User

ZOJ 2819 Average score Time limit:2 Sec Memory limit:60 MB Topic Connection

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 is 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 both classes. If you were in the other class, the average scores of both classes would increase. "

Now, you're given the scores of all students in the and the classes, except for the Bob ' s. Please calculate the possible range of Bob ' s score. All scores shall is integers within [0, 100].

Input

There is multiple test cases. The first line of input contains an integer indicating the number of the T test cases. For each test case:

The first line contains integers N (2 <= N <=) and M (1 <= M <=) indicating the numb Er 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 , ..., representing the scores of other AN-1 students in Bob's class .

The last line contains M integers B1 , B2 , ..., representing the scores of students in the other BM class.

Output

For each test case, the output of the integers representing the minimal possible score and the maximal possible score of Bob.

It is guaranteed, the solution always exists.


Sample Input
24 35 5 54 4 36 55 5 4 5 31 3 2 2 1

Sample Output4 4 2 4HINT

Test Instructions give you two classes, tell you to throw Bob to Class B, the average of two classes will rise, and then ask you, Bob's score on the lower limit is how much

Exercises

The violent enumeration averaged, and then apparently Bob had a lower average than the first class, and it was better than the average of a second class.

Code:

//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>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 200001#defineMoD 10007#defineEPS 1e-9//const int INF=0X7FFFFFFF; //infinitely LargeConst intinf=0x3f3f3f3f;/**///**************************************************************************************inline ll read () {intx=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}intMain () {intT; T=read ();  while(t--)    {        intn,m; N=read (), m=read (); intans1=0, ans2=0;  for(intI=0; i<n-1; i++)        {            intx=read (); Ans1+=x; }         for(intI=0; i<m;i++)        {            intx=read (); Ans2+=x; }        intt1=0, t2=0;  while(t1*m<=ans2) T1++;  while(T2* (n1) <ans1) T2++; printf ("%d%d\n", t1,t2-1); }    return 0;}

ZOJ 2819 Average score mudanjiang field game a water problem/registration question

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.