ZOJ3819 ACM-ICPC 2014 Asia Regional Competition Site Mudanjiang Division A title Average score registration Title

Source: Internet
Author: User

Average Score Time limit: 2 Seconds Memory Limit: 131072 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 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 Output
4 42 4
 This question is Mudanjiang division's check-in question, proves to have come ~ ~ ~ ~ actually is very water topic. The topic tells you that your average score is higher than the second class, lower than the first one. Let you find the score up and down the interval, directly get the average score and then whether the precision search or violence to find can, anyway, the highest total score is 5000, how to find no tle, the method is arbitrary, is a very water topic. Not much to say, the detailed AC program such as the following: 
#include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <cstdlib > #include <algorithm> #include <map> #include <vector> #include <queue>using namespace std; int main () {//   freopen ("In.txt", "R", stdin);    int t;    cin>>t;    while (t--)    {        int n,m;        scanf ("%d%d", &n,&m);        int sum1=0,sum2=0;        for (int i=0;i<n-1;i++)        {            int it;            scanf ("%d", &it);            Sum1+=it;        }        for (int i=0;i<m;i++)        {            int it;            scanf ("%d", &it);            Sum2+=it;        }        int ti=1;        while (ti*m<=sum2)            ti++;        int l=ti;        while (ti* (n-1) <sum1)            ti++;        int r=ti-1;        printf ("%d%d\n", l,r);    }    return 0;}


Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

ZOJ3819 ACM-ICPC 2014 Asia Regional Competition Site Mudanjiang Division A title Average score registration Title

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.