Back To School '17: Physics

View as PDF

Submit solution

Points: 7
Time limit: 3.0s
Memory limit: 256M

Author:
Problem type

To scientifically round a real number, find the integer that is the closest to the real number. If there are two equally close integers, choose the even integer. A few examples are listed in the table below.

Real number Rounded value Comment
3.14 3 3 is the closest integer to 3.14.
8.50 8 8 and 9 are equally close to 8.50, but 8 is chosen because it is even.
9.00 9 9 is the closest integer to 9.00. In fact, they are the same number.

In the remainder of the problem statement, \operatorname{round}(x) will refer to the rounded value of x.


Percentages may not add up to 100% due to rounding.

Wilson is learning about how to scientifically round numbers to the nearest integer on the first day of his physics class. A little later, Wilson is trying out some easy physics problems; he adds up a bunch of distances and scientifically rounds the sum. Sometimes Wilson wonders about the accuracy of his results.

On his next problem, he needs to add together N distances. The i^{th} distance is r_i metres and the answer is \operatorname{round}(r_1 + \dots + r_N) metres. Wilson changes the i^{th} distance to \operatorname{round}(r_i) metres and soon forgot r_i. By doing this, he introduced multiple possible answers to his physics problem. Now, Wilson doesn't know the possible answers!

What is the minimum and maximum possible answer to the physics problem?

Constraints

For 60\% of the points, 1 \le N \le 10 and 1 \le \operatorname{round}(r_i) \le 10.

For 100\% of the points, 1 \le N \le 10^5 and 1 \le \operatorname{round}(r_i) \le 10^9.

If exactly one output is wrong, 60\% of the points will be awarded for that test case.

Input Specification

The first integer will contain N.

On each of the next N lines, the i^{th} of these lines will contain the integer \operatorname{round}(r_i).

Output Specification

The first line should contain the minimum possible value of \operatorname{round}(r_1 + \dots + r_N).

The second line should contain the maximum possible value of \operatorname{round}(r_1 + \dots + r_N).

Each value should be an integer, and do not print the integer with a . character.

Sample Input 1

1
5

Sample Output 1

5
5

Sample Input 2

2
49
50

Sample Output 2

98
100

Sample Input 3

3
10
10
10

Sample Output 3

28
32

Explanation for Sample Output 3

28 can be achieved with r_1 = r_2 = r_3 = 9.5 since \operatorname{round}(r_1 + r_2 + r_3) = \operatorname{round}(28.5) = 28.

32 can be achieved with r_1 = r_2 = r_3 = 10.5 since \operatorname{round}(r_1 + r_2 + r_3) = \operatorname{round}(31.5) = 32.


Comments


  • 0
    KevinWan  commented on Sept. 10, 2017, 11:22 p.m.

    for sample output 3, doesn't round(28.5)=29, and round(10.5)=11


    • 6
      d  commented on Sept. 11, 2017, 12:43 a.m.

      If there are two equally close integers, choose the even integer.


  • 0
    sunnylancoder  commented on Sept. 10, 2017, 5:12 p.m.

    I got 1 case wrong, and got an 85/100. I got 2 cases wrong and got 90/100. Is this intended?


    • 1
      aurpine  commented on Sept. 10, 2017, 10:50 p.m.

      There are partials for test cases. So it may say AC and say 3/5 on the side instead of 5/5. This means that you only got one of the answers correct.