-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path74_boj_2108.py
More file actions
44 lines (35 loc) · 774 Bytes
/
74_boj_2108.py
File metadata and controls
44 lines (35 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from queue import PriorityQueue
arr = [0] * 8001
pq = PriorityQueue()
n = int(sys.stdin.readline())
summ = 0
for _ in range(n) :
buf = int(sys.stdin.readline())
summ += buf
arr[buf + 4000] += 1
pq.put(buf)
print(round(summ/n))
first = 0;last = 0
freq_value = []
freq_cnt = 0
for i in range(n) :
now = pq.get()
if arr[now + 4000] > freq_cnt :
freq_cnt = arr[now + 4000]
freq_value = [now]
elif arr[now + 4000] == freq_cnt :
freq_value.append(now)
if i == 0 :
first = now
if i == (n//2) :
print(now)
if i == n-1 :
last = now
freq_value = list(set(freq_value))
freq_value.sort()
try :
print(freq_value[1])
except :
print(freq_value[0])
print(last-first)