NCPC26 ending

This commit is contained in:
Joel committed 2026-10-03 16:16:18 +02:00
1 parent fbd41d8ac7
commit 2820c84507
34 files changed
+612 -311

No files matched your search

+38
View File
@@ -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]))