NCPC26 ending
This commit is contained in:
34 files changed
+612
-311
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import sys
|
||||
|
||||
for line in sys.stdin:
|
||||
pices = int(line)
|
||||
|
||||
if (pices == 0):
|
||||
print(0)
|
||||
exit()
|
||||
|
||||
arr = list()
|
||||
arr = map(int, input().split())
|
||||
|
||||
ar = sorted(arr)
|
||||
|
||||
half = ar[pices-1] / 2
|
||||
|
||||
i = 0
|
||||
index = 0
|
||||
closest = 1001
|
||||
|
||||
if (pices == 1):
|
||||
print(ar[0])
|
||||
exit()
|
||||
|
||||
while ar[i] <= half:
|
||||
i += 1
|
||||
|
||||
if i > 0:
|
||||
if (ar[i] - half) <= closest:
|
||||
closest = (ar[i] - half)
|
||||
index = i
|
||||
if (half - ar[i-1]) <= closest:
|
||||
closest = (ar[i-1] - half)
|
||||
index = i-1
|
||||
else:
|
||||
index = 0
|
||||
|
||||
print(max((ar[pices-1] - ar[index]), ar[index]))
|
||||
Reference in new issue
Block a user