DMOPC '19 Contest 2 P1 - Box and Whiskers

View as PDF

Submit solution


Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Veshy is struggling in data management class. Veshy forgot how to make a box and whisker plot, so he wants you to tell him the important values to make the plot of the N data points a1,a2,,aN. He gives you: the minimum, maximum, Q1 (Quartile 1 or median of the first N2 elements), Q2 (Quartile 2 or median of the entire data), and Q3 (Quartile 3 or median of the last N2 elements) of the sorted list.
For example, if the data set was {1,2,3,4,5,6,7,8,9,10}, the important values in their respective order would be: 1, 10, 3, 5.5, 8
Another example, if the data set was {1,2,3,4,5,6,7,8,9,10,11}, the important values in their respective order would be: 1, 11, 3, 6, 9

Constraints

In all tests,
5N105
0ai106
All numbers are guaranteed to be whole numbers.

Input Specification

The first line contains a number, N, the number of data points.
The second line contains N numbers separated by spaces, the data points Veshy gives you: a1,a2,,aN
Note: the data points are not guaranteed to be in sorted order.

Output Specification

Output the minimum, maximum, Q1, Q2, Q3, in that order separated by spaces on a single line.
Note: your answer will be judged as correct if it is within an absolute or relative error of 106.

Sample Input 1

Copy
10
1 2 3 4 5 6 7 8 9 10

Sample Output 1

Copy
1 10 3 5.5 8

Sample Input 2

Copy
11
1 2 3 4 5 6 7 8 9 10 11

Sample Output 2

Copy
1 11 3 6 9

Comments


  • -1
    lwale1  commented on Feb. 25, 2022, 7:37 p.m.

    I get the first 4 right, but the 5th one is WA. Can someone take a look at my code please?


    • 1
      Spitfire720  commented on Feb. 25, 2022, 9:13 p.m.

      Try this test case:

      Copy
      5
      999995 999996 999997 999998 999999

      Your program doesn't print decimals.


      • 0
        lwale1  commented on Feb. 26, 2022, 5:03 p.m.

        Thanks a lot, that did it