[BOJ 6177] Statistics
View as PDF
Submit solution
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text
Points:
1
Time limit:
1.0s
Memory limit:
128M
Problem type
Allowed languages
The cows have enrolled in elementary statistics and are having a tough time with their homework. Please help them.</p>
Given a set of N (1 <= N <= 500) numbers, X_i (-5,000 <= X_i <= 5000), calculate two statistics:
- The mean (sum of the numbers divided by N)
- The median (if N is odd, the middle number when the N numbers are sorted; if N is even, the mean of the two middle numbers when the N numbers are sorted)
Your answer will be considered correct if it is within 0.002 of the official answer.
입력 형식
- Line 1: A single integer: N
- Lines 2..N+1: Line i+1 contains a single integer: X_i </ul>
- Line 1: The mean of the input set
- Line 2: The median of the input set </ul>
출력 형식
예제 입력
5
12
4
6
8
2
예제 출력
6.400000
6.000000
힌트
(12+4+6+8+2)/5=6.4</p>
Middle number of the set {2, 4, 6, 8, 12} is 6
Comments