-
Notifications
You must be signed in to change notification settings - Fork 1
/
aac2p2.py
36 lines (34 loc) · 912 Bytes
/
aac2p2.py
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
from sys import stdin, exit
input = stdin.readline
num = int(input())
numbers = sorted(int(x) for x in input().split())
freq = {}
if num == 2 and numbers[0] != numbers[1]:
if ((numbers[0] + numbers[1]) / 2) % 1 == 0:
print(2)
else:
print(1)
exit()
for i in numbers:
if i in freq:
freq[i] += 1
else:
freq[i] = 1
maximum = max(freq.values())
for i in freq:
if freq[i] == maximum:
for a in range(num):
if numbers[a] == i:
continue
low, high = a + 1, num
while high - low > 1:
mid = (low + high) // 2
avg = (numbers[a] + numbers[mid]) / 2
if avg == i:
print(maximum + 2)
exit()
elif avg < i:
low = mid
else:
high = mid
print(maximum + 1)