You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
X = map(lambda x:int(x)-1, raw_input().strip().split())
X.sort()
for i in xrange(len(X)-1): # make it as circular array
X.append(X[i]+N)
prefix = [0]
for x in X:
prefix.append(prefix[-1]+x)
return min((prefix[(i+W-1)+1]-prefix[(i+(i+W-1)+1)//2])-(prefix[(i+(i+W-1))//2+1]-prefix[i]) for i in xrange(W)) # find median of window with min number of moves