Here is the task: https://codeforces.com/problemset/problem/492/B And here is my code:
n, l = map(int, input().split())
lantern = []
for i in range(n):
a = int(input())
lantern.append(a)
lantern.sort()
print(lantern)
if (lantern[0] >= (l-lantern[n-1])):
r = lantern[0]
else:
r = l-lantern[n-1]
for i in range(n-2):
if (lantern[i 1] - lantern[i])/2 > r:
r = (lantern[i 1] - lantern[i])/2
print(r)
So, what should I correct?
CodePudding user response:
The n
integers are on a single line, and your code handles n
line separated inputs. Change it to
n, l = map(int, input().split())
lantern = list(map(int, input().split()))
lantern.sort()