TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
max_diff = 0
for idx in range(len(a)-1):
  diff = a[idx+1] - a[idx]
  if max_diff < diff:
    max_diff = diff

ans = k - max_diff
print(ans)


k, n = input().split()
a = list(map(int, input().split()))
a.sorted()
max_diff = 0
for idx in range(len(a)-1):
  diff = a[idx+1] - a[idx]
  if max_diff < diff:
    max_diff = diff

ans = k - max_diff
print(ans)

k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
max_diff = k - a[n-1] + a[0]
for idx in range(len(a)-1):
  diff = a[idx+1] - a[idx]
  if max_diff < diff:
    max_diff = diff
max_diff = max_diff
ans = k - max_diff
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K = int(input())
N = int(input())
lists = [int(x) for x in input().split()]
lists.sort()
sor = []
for i in range(N-1):
    sor.append(lists[i+1]-lists[i])
sor.append(K-lists[N-1]+lists[0])
print(K-max(sor))

[K,N]= [int(x) for x in input().split()]

lists = [int(x) for x in input().split()]
lists.sort()
sor = []
for i in range(N-1):
    sor.append(lists[i+1]-lists[i])
sor.append(K-lists[N-1]+lists[0])
print(K-max(sor))

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n=map(int,input())
l=list(map(int,input()))
v=[k-l[-1]+l[0]]
for i in range(n-1):
  v.append(l[i+1]-l[i])
v.sort()
print(k-v[-1])

k,n=map(int,input.split())
l=list(map(int,input.split()))
v=[k-l[-1]+l[0]]
for i in range(n-1):
  v.append(l[i+1]-l[i])
v.sort()
print(k-v[-1])

k,n=map(int,input().split())
l=list(map(int,input().split()))
v=[k-l[-1]+l[0]]
for i in range(n-1):
  v.append(l[i+1]-l[i])
v.sort()
print(k-v[-1])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
print(max(abs(a1 - a2)))

import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
print(max(abs(a1 - a2)))

import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = np.append(a, a[0]+k)
print(k - max(a[1:] - a[:-1]))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K,N=map(int,input().split())
A=sorted(list(map(int,input().split())))

max_a = max(A)
min_a = min(A)
diff_min = max_a - min_a

if diff_min <= K/2:
    print(diff_min)
else:
    for i in range(1,N-1):
        tmp = K - (A[i+1] - A[i])
        if tmp < diff_min:
            diff_min = tmp
        tmp = K - (A[i] - A[i-1])
        if tmp < diff_min:
            diff_min = tmp

print(diff_min)


K,N=map(int,input().split())
A=sorted(list(map(int,input().split())))

max_a = max(A)
min_a = min(A)
diff_min = max_a - min_a

if N == 2:
    if A[1] - A[0] < K - (A[1] - A[0]):
        diff_min = A[1] - A[0]
    else:
        diff_min = K - (A[1] - A[0])
else:
    for i in range(1,N-1):
        tmp = K - (A[i+1] - A[i])
        if tmp < diff_min:
            diff_min = tmp
        tmp = K - (A[i] - A[i-1])
        if tmp < diff_min:
            diff_min = tmp

print(diff_min)


Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if a[0]==0:
    lastlength = 20-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = A[N-1]-A[0]
    if lastlength>max2:
        max2=lastlength
print(20-max2)

K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
sum = 0.0
for i in range(0,N):
    sum = sum+A[i]
average = sum/N
print(average)
    

K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
lastlength = 20-A[N-1]
if lastlength >max2:
    max2=lastlength
print(20-max2)
    

K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
print(20-max2)

K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if A[0]==0:
    lastlength = K-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = K-A[N-1]+A[0]
    if lastlength>max2:
        max2=lastlength
print(K-max2)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = map(int,input().split())
a=list(map(int,input().split()))
print(sum(a)//2)

k,n = map(int,input().split())
a=list(map(int,input().split()))
b=[i for i in a if i<k//2]
c=[i for i in a if i>=k//2]
print(k-max(c)-max(b))

k,n = map(int,input().split())
a=list(map(int,input().split()))
ans=(a[0]-a[-1])+k
for i in range(n-1):
  ans=max(a[i+1]-a[i],ans)
print(k-ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import numpy as np
a,b=list(map(int,input().split()))
C=list(map(int,input().split()))

def getnear(list,num):
  near=np.abs(np.asarray(list)-num).argmin()
  return list[near]

S=sorted(C)
H=getnear(C,a/2)
r=abs(H+abs(a-S[0]))
l=abs(H+abs(a-S[-1]))
if r>l:
  print(l)
else:
  print(r)

a,b=map(int,input().split())
L=list(map(int,input().split()))
rest=L[0]+a-L[-1]
for i in range(b-1):
  U=L[i+1]-L[i]
  rest=max(rest,U)
print(a-rest)
  

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K,N = map(int,input().split())
A_list = list(map(int,input().split())
A_list.append(K+A_list[0])
A_split = []
i for in range(N):
    split = A_list[i+1] - A_list[i]
    A_split.append(split)

A_split.pop(A_split.index(max(A_split)))
print(sum(A_split))

K,N = map(int,input().split())
A_list = list(map(int,input().split()))
A_list.append(K + A_list[0])
A_split = []
for i in range(N):
    A_split.append(A_list[i+1]-A_list[i])

A_split.pop(A_split.index(max(A_split)))
print(sum(A_split))

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = list(map(int, input().split()))
a = list(map(int, input().split()))

for i, num in enumerate(a):
    if num>(k/2):
        a[i] = num - k

print(max(a) - min(a))



k,n = list(map(int, input().split()))
a = list(map(int, input().split()))
"""
ans = max(a) - min(a)
for i, num in enumerate(a):
    if num>(k/2):
        a[i] = num - k

print(min(ans,max(a) - min(a)))

min
abs(ai-bi)
abs(ai-(bi-k))
"""
def saitan(num1,num2,k):
    return min(abs(num1 - num2), abs(num1-(num2-k)))

bb = saitan(a[0], a[n-1], k)
for i in range(1,n):
    bb = max(bb, saitan(a[i], a[i-1], k))

print(k-bb)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = map(int, input().split())
points = list(map(int, input().split()))
max_index = -1
max_value = -1

for index in range(1, N):
  d = points[index] - points[index-1] 
  if d > max_value:
    max_index = index
    max_value = d

start = K - points[max_index]
end   = points[max_index-1]

print(start + end)

K, N = map(int, input().split())
points = list(map(int, input().split()))
max_index = -1
max_value = -1

for index in range(1, N):
  d = points[index] - points[index-1] 
  if d > max_value:
    max_index = index
    max_value = d

start = K - points[max_index]
end   = points[max_index-1]

l = start + end
plane_l = points[-1] - points[0]
if l <= plane_l:
  print(l)
else:
  print(plane_l)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = input().split()
K = int(K)
N = int(N)
A = list(map(int, input().split()))

max = 0
for i in range(1, N):
    if max < (A[i] - A[i-1]):
        max = A[i] - A[i-1]
if (max < A[N-1] - A[0]) and ( A[N-1] - A[0]) < K/2:
    max = A[N-1] - A[0]
print(K - max)


K, N = input().split()
K = int(K)
N = int(N)
A = list(map(int, input().split()))
A.append(K + A[0])
max = 0
for i in range(N):
    if max < (A[i+1] - A[i]):
        max = A[i+1] - A[i]
print(K - max)


Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    k,n = list((map(int, input().split(' '))))
    a = list(map(int, input().split(' ')))
    a = quick_sort
    result = 0
    for i in range(1,n):
        length = a[i]-a[i-1]
        result = max(length, result)
        
    length = a[0] + (k-a[n-1])
    result = max(result, length)
    print(k-result)
    





      

#     print(i)
#     if i%5==4:
#         break


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    k,n = list((map(int, input().split(' '))))
    a = list(map(int, input().split(' ')))
    a = quick_sort
    result = 0
    for i in range(1,n):
        length = a[i]-a[i-1]
        result = max(length, result)
        
    length = a[0] + (k-a[n-1])
    result = max(result, length)
    print(k-result)
    





      

#     print(i)
#     if i%5==4:
#         break


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    k,n = list((map(int, input().split(' '))))
    a = list(map(int, input().split(' ')))
    
    result = 0
    for i in range(1,n):
        length = a[i]-a[i-1]
        result = max(length, result)
        
    length = a[0] + (k-a[n-1])
    result = max(result, length)
    print(k-result)
    





      

#     print(i)
#     if i%5==4:
#         break

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = map(int, input().split())
A = list(map(int, input().split()))

x = max(A)
print(sum(A) - x)

k,n = map(int, input().split())
A = list(map(int, input().split()))

x = k - A[n-1]
z = A[0]
x = max(x,z)
for i in range(1,n):
    y = A[i]-A[i-1]
    if y > x:
        x = y

print(k-x)

k,n = map(int, input().split())
A = list(map(int, input().split()))

x = k - A[-1]
for i in range(1,n):
    y = A[i]-A[i-1]
    if y > x:
        x = y

print(k-x)

k,n = map(int, input().split())
A = list(map(int, input().split()))

x = k + A[0] - A[n-1]

for i in range(1,n):
    y = A[i]-A[i-1]
    if y > x:
        x = y

print(k-x)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
route = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]
for i in range(1,arrayNM[1]):
  route.append(array[i] - array[i-1])
  
Max = max(route)
maxIndex = route.index(Max)
distance = 0

for i in range(0,maxIndex):
  distance += route[i]

for i in range(maxIndex + 1, array[1]):
  distance += route[i]

print(distance)
print(route)



arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
route = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]
for i in range(1,arrayNM[1]):
  route.append(array[i] - array[i-1])
  
Max = max(route)
maxIndex = route.index(Max)
distance = 0

for i in range(0,maxIndex):
  distance += route[i]

for i in range(maxIndex + 1, array[1]):
  distance += route[i]

print(distance)



arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
route = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]
for i in range(1,arrayNM[1]):
  route.append(array[i] - array[i-1])
  
Max = max(route)
maxIndex = route.index(Max)
distance = 0

for i in range(0,maxIndex):
  distance += route[i]

for i in range(maxIndex, array[0]):
  distance += route[i]

print(distance)
print(route)



arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
route = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]
for i in range(1,arrayNM[1]):
  route.append(array[i] - array[i-1])
  
Max = max(route)
maxIndex = route.index(Max)
distance = 0

for i in range(0,maxIndex):
  distance += route[i]

for i in range(maxIndex + 1, arrayNM[1]):
  distance += route[i]

print(distance)



Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = map(int, input().split())
A = [int(i) for i in input().split()]

max_dist = A_dist[0] = A[0] + (K - A[-1])
for i in range(1, N):
    if A[i] - A[i-1] > min_dist:
        max_dist = A[i] - A[i-1]

print(K - max_dist)

K, N = map(int, input().split())
A = [int(i) for i in input().split()]

max_dist = A[0] + (K - A[-1])
for i in range(1, N):
    if A[i] - A[i-1] > max_dist:
        max_dist = A[i] - A[i-1]

print(K - max_dist)

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n=map(int,input().split())
A=list(map(int,input().split()))
d=[0]*len(A)
for i in range(len(A)):
  if i==0:
    d[i]=A[len(A)]-A[i]
  else:
    d[i]=k-A[i] + A[i-1]
    
print(min(A))


k,n=map(int,input().split())
A=list(map(int,input().split()))
d=[0]*n
d[0]=A[n-1]-A[0]
for i in range(1,n):
  d[i]=k-A[i] + A[i-1]
    
print(min(d))


Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n=map(int,input().split())
list=list(input().split())
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))

k,n=map(int,input().split())
list=list(map(int,input().split()))
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
f=list(map(int,input().split()))
k=f[0];n=f[1]
dists=list(map(int,input().split()))
prev=0
maxdist=0
for d in range(len(dists)):
  maxdist=max(maxdist,abs(prev-dists[d]))
  prev=dists[d]
a=max(maxdist,maxdist-dists[len(dists)-1]+dists[0])  
ans=k-a
print(ans)


f=list(map(int,input().split()))
k=f[0];n=f[1]
dists=list(map(int,input().split()))
prev=0
maxdist=0
for d in range(1,len(dists)):
  maxdist=max(maxdist,abs(prev-dists[d]))
  prev=dists[d]
a=max(maxdist,maxdist-dists[len(dists)]+dists[0])  
ans=k-a
print(ans)

f=list(map(int,input().split()))
k=f[0];n=f[1]
dists=list(map(int,input().split()))
prev=0
maxdist=0
for d in range(n):
  maxdist=max(maxdist,abs(prev-dists[d]))
  prev=dists[d]
maxdist=max(maxdist,maxdist-dists[len(dists)-1]+dists[0])  
ans=k-maxdist
print(ans)


k,n = map(int, input().split())
a = list(map(int, input().split()))
max_dis = 0
for i in range(n):
    if i == n-1:
        max_dis = max(max_dis,a[0]+k-a[i])
    else:
        max_dis = max(max_dis,a[i+1]-a[i])
print(k-max_dis)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
def main():
    K,N = map(int,input().split())
    A = list(map(int,input().split()))
    Aa = []
    for i in range(1,N):
        Aa.append(A[i]-A[i-1])
    Aa.append(K-A[N-1]+A[0])
    print(Aa)
    print(sum(Aa)-max(Aa))

if __name__ == "__main__":
    main()

def main():
    K,N = map(int,input().split())
    A = list(map(int,input().split()))
    Aa = []
    for i in range(1,N):
        Aa.append(A[i]-A[i-1])
    Aa.append(K-A[N-1]+A[0])
    print(sum(Aa)-max(Aa))

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])

result = []

for i in range(N):
    if i == N - 1:
        result.append(K - A[i] + A[0])
    else:
        result.appnd(A[i + 1] - A[i])

result.sort()

print(sum(result[:-1]))


K, N = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])

result = []

for i in range(N):
    if i == N - 1:
        result.append(K - A[i] + A[0])
    else:
        result.append(A[i + 1] - A[i])

result.sort()

print(sum(result[:-1]))


Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import copy

K,N = map(int, input().split())
An = list(map(int, input().split()))
ans = [max(An) - min(An)]
for i in range(len(An)/2,len(An)):
    A_list = copy.copy(An)
    A_list[i] = A_list[i]-K
    ans.append(max(A_list) - min(A_list))
print(min(ans))

import numpy as np

K,N = map(int, input().split())
An = list(map(int, input().split()))
arr = np.array(An)
arr = np.diff(arr)
ans = list(arr)
ans.append(K-An[-1]+An[0])
# print(ans)
ans.remove(max(ans))
print(sum(ans))

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read

K, N, *A = map(int, read.split())

max_distance = K + (A[0] - A[-1])
 
for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

K, N = map(int, input().split())
A = list(map(int, intput().split()))

max_distance = K + (A[0] - A[-1])

for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
 
max_distance = K + (A[0] - A[-1])
 
for i in range(1, N):
  max_distance = max(max_distance, A[i] - A[i - 1])
  
print(K - max_distance)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for a in A:
    if a > K // 2:
        ans += a - K // 2
    else:
        ans += a

print(ans)


K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0] + K)
max_diff = -1
for i in range(1, N + 1):
    max_diff = max(max_diff, A[i] - A[i - 1])
print(K - max_diff)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
mini = -1
for i in a:
    tmp = a - i
    tmp = np.abs(tmp)
    if mini == -1:
        mini = max(tmp) - min(tmp)
    else:
        mini = min(mini, max(tmp) - min(tmp))
print(mini)


import numpy as np
k, n = map(int, input().split())
a = np.array(list(map(int, input().split())))
maxi = -1
for i in range(0, len(a)):
    if i == 0:
        tmp = max(abs((a[i] + k) - a[i - 1]), abs(a[i] - a[i + 1]))
    elif 0 < i < len(a) - 1:
        tmp = max(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1]))
    else:
        tmp = max(abs(a[i] - a[i-1]), abs(a[i] - (a[0] + k)))
    if maxi == -1:
        maxi = tmp
    else:
        maxi = max(maxi, tmp)
print(k - maxi)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K , N = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = []

max = K - A[-1] + A[0]
B.append(max)
ind = 0
for i in range(1, N, 1):
	_max = A[i] - A[i-1]
	B.append(_max)
	if _max < 0:
		_max = K + _max
	if _max > max:
		max = _max
		ind = i
dis1 = 0
for i in range(1, N, 1):
	if i + ind >= N:
		dis1 += B[(i + ind) - N]
	else:
		dis1 += B[(i + ind)]
	print(dis1)

K , N = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = []

max = K - A[-1] + A[0]
B.append(max)
ind = 0
for i in range(1, N):
	_max = A[i] - A[i-1]
	B.append(_max)
	if _max < 0:
		_max = K + _max
	if _max > max:
		max = _max
		ind = i
dis1 = 0

for i in range(1, N):
	if i + ind >= N:
		dis1 += B[(i + ind) - N]
	else:
		dis1 += B[(i + ind)]
        
print(dis1)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
max_dist = 0
for i in range(len(A)-1):
  if A[i+1]-A[i] > max_dist:
    max_dist = A[i+1]-A[i] 
print(k-max_dist)
  

k,n = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
max_dist = 0
for i in range(len(A)-1):
  if A[i+1]-A[i] > max_dist:
    max_dist = A[i+1]-A[i] 
if A[0]+k-A[-1] > max_dist:
  max_dist = A[0]+k-A[-1]
print(k-max_dist)
  


Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
import numpy as np
K, N = map(int, input().split())
A = np.array(list(map(int, input().split())))
diff = A[1:] - A[:-1]
diff = np.append(diff, K + A[0] - A[-1])
print('diff', diff)
ans = diff.sum() - diff.max()
print(ans)


import numpy as np
K, N = map(int, input().split())
A = np.array(list(map(int, input().split())))
diff = A[1:] - A[:-1]
diff = np.append(diff, K + A[0] - A[-1])
# print('diff', diff)
ans = diff.sum() - diff.max()
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = map(int,input().split())

Ai = list(map(int,input().split()))
kyori = []

for x in range(n-1):
  kyori.append(Ai[x+1]-Ai[x])
  
kyori.append(Ai[0]+k-Ai[n-1])

kyoto.remove(max(kyori))

print(sum(kyori))


k,n = map(int,input().split())

Ai = list(map(int,input().split()))
kyori = []

for x in range(n-1):
  kyori.append(Ai[x+1]-Ai[x])
  
kyori.append(Ai[0]+k-Ai[n-1])

kyori.remove(max(kyori))

print(sum(kyori))


Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K,N = list(map(int,input().split()))
A = list(map(int,input().split()))

distence_list = [x for x in [ A[i+1] - A[i] for i in range(len(A)-1)]]

m = max(distence_list)

print(K-m)


K,N = list(map(int,input().split()))
A = list(map(int,input().split()))

distence_list = [x for x in [ A[i+1] - A[i] for i in range(len(A)-1)]]

m = max(distence_list)

x = K - A[-1] + A[0]

if m > x:
  print(K-m)
else:
  print(A[-1] - A[0])


Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
def main():
    x, y = map(int, input().split())
    a = list(map(int, input().split()))
    cost = 10*10
    for i in range(n-1):
        cost = min(cost, k - abs(a[i]-a[i+1]))
    print(min(cost, k-abs(a[0]+k-a[n-1])))

if __name__ == "__main__":
    main()

def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    cost = a[n-1]-a[0]
    for i in range(n-1):
        cost = min(cost, k-(a[i+1]-a[i]))
    print(cost)

if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k, n = input().split()
a_list_org = list(map(int,input().split()))
a_list_org.sort()
a_list = [a - int(k) if (a > int(k) // 2) else a for a in a_list_org]
a_list.sort()
print(a_list)
ans1 = 0
ans2 = 0
for a in a_list:
    if a == a_list[0]:
        pre = a
        continue
    else:
        ans1 += (a - pre)
        pre = a
for a in a_list_org:
    if a == a_list_org[0]:
        pre = a
        continue
    else:
        ans2 += (a - pre)
        pre = a
ans = min(ans1, ans2)
print(ans)

k, n = input().split()
a_list_org = list(map(int,input().split()))
a_list = []
for a in a_list_org:
    if a == a_list_org[0]:
        pre = a
        a_list.append(int(k) - a_list_org[-1] + a)
    else:
        a_list.append(a - pre)
        pre = a
a_list.remove(max(a_list))
print(sum(a_list))

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
(n,m)=map(int,input().split())
a=input().split()
a=list(map(int,a))
l=[]
k=0
a=sorted(a)
for i in range(m-1):
    d=abs(a[i]-a[i+1])
    k=k+d
    l.append(d)
# k=k-d
c=n-k
print(c)
l=sorted(l)
l1=sum(l)
print(l1-l[-1])

(n,m)=map(int,input().split())
a=input().split()
a=list(map(int,a))
l=[]
k=0
a=sorted(a)
for i in range(m-1):
    d=abs(a[i]-a[i+1])
    k=k+d
    l.append(d)
# k=k-d
c=n-k
l.append(c)
l=sorted(l)
l1=sum(l)
print(l1-l[-1])

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n-1):
    b.append(a[i+1]-a[i])
b.append((k-a[n-1])+a[0])
print(b)
print(k-max(b))

k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n-1):
    b.append(a[i+1]-a[i])
b.append((k-a[n-1])+a[0])
print(k-max(b))

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int64_t n, k;
  cin >> k >> n;
  vector<int64_t> li(n * 2);
  for (int i = 0; i < n; ++i)
  {
    cin >> li[i];
    li[i + n] = li[i] - k;
  }
  sort(li.begin(), li.end());
  int64_t ans = 10e9;
  for (int i = 0; i < 2 * n - (n - 1); ++i)
    ans = min(ans, abs(li[i] - li[i + n - 1]));
  cout << ans << "\n";
}

k, n = map(int, input().split())
li = list(map(int, input().split()))

tmp = [0] * n
for i in range(n):
    tmp[i] = li[i] - k
li = li + tmp
li.sort()
ans = 10**9
for i in range(len(li) - n+1):
    ans = min(ans, abs(li[i] - li[i + n-1]))
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = map(int, input().split())

house_list = list(map(int, input().split()))
print(house_list)


if 0 in house_list:
    print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))
else:
    print(min(house_list[-1] - house_list[1]))

K, N = map(int, input().split())

house_list = list(map(int, input().split()))
#print(house_list)


if 0 in house_list:
    print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))
else:
    print(min(house_list[-1] - house_list[1]))

K, N = map(int, input().split())

house_list = list(map(int, input().split()))
#print(house_list)


if 0 in house_list:
    print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))
else:
    print(min(house_list[-1] - house_list[0]))

K, N = map(int, input().split())

house_list = list(map(int, input().split()))
#print(house_list)

dist_list = [K - house_list[-1] + house_list[0]]
#print(dist_list)

for n in range(1, N):
    dist_list.append(house_list[n] - house_list[n-1])
print(K - max(dist_list))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = map(int, input().split())

a = [ int (x) for x in input().split() ]

kyori_sa = []

print(len(a)-1)


for i in range(n):
  if i == len(a)-1:
    kyori_sa.append(a[0] - ( k - a[i] ))
  else:
    kyori_sa.append(a[i+1] - a[i])

print(k-max(kyori_sa))

k,n = map(int, input().split())

a = [ int (x) for x in input().split() ]

kyori_sa = []

for i in range(n):
  if i == len(a)-1:
    kyori_sa.append(a[0] + ( k - a[i] ))
  else:
    kyori_sa.append(a[i+1] - a[i])

print(k-max(kyori_sa))
     

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K,N=map(int,input().split())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(N-1):
    X=a_list[i+1]-a_list[i]
    b_list.append(abs(X))
b_list.append(K-a_list[-1]+a_list[0])
print(b_list)
print(K-max(b_list))

K,N=map(int,input().split())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(N-1):
    X=a_list[i+1]-a_list[i]
    b_list.append(abs(X))
b_list.append(K-a_list[-1]+a_list[0])
print(K-max(b_list))

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
K, N = map(int,input().split())
a = list(map(int,input().split()))
x = [a[0]-a[-1]+K]
for i in range(1,N):
    x.append(a[i]-a[i-1])
print(x)
print(K-max(x))

K, N = map(int,input().split())
a = list(map(int,input().split()))
x = [a[0]-a[-1]+K]
for i in range(1,N):
    x.append(a[i]-a[i-1])
print(K-max(x))

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
kn=list(map(int, input().split()))
a=list(map(int, input().split()))
k=kn[0]
n=kn[1]
maxdis=a[n-1]+a[0]
for i in range(n-1):
    if maxdis<(a[i+1]-a[i]):
        maxdis=(a[i+1]-a[i])
print(k-maxdis)

kn=list(map(int, input().split()))
a=list(map(int, input().split()))
k=kn[0]
n=kn[1]
maxdis=k-a[n-1]+a[0]
#print(maxdis)
for i in range(n-1):
    if maxdis<(a[i+1]-a[i]):
        maxdis=(a[i+1]-a[i])
        #print(i)
        #print(maxdis)
print(k-maxdis)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
e = list(map(int,input().split()))
K = e[0]
N = e[1]
a = list(map(int,input().split()))
c = [a[i+1] - a[i] for i in range(N-1)]
f = a[0]+20 - a[N-1]
c.append(f)
d = max(c)
print(c)
print(d)
print(K - d)


K,N = map(int,input().split())
a = list(map(int,input().split()))
c = a[1:]-a[:-1]
d = max(c)
print(K - d)


e = list(map(int,input().split()))
K = e[0]
N = e[1]
a = list(map(int,input().split()))
c = [a[i+1] - a[i] for i in range(N-1)]
f = a[0]+ K - a[N-1]
c.append(f)
d = max(c)
print(K - d)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n=map(int,input().split())
lista=list(map(int,input().split())) 
lista.append(lista[0]+k)
ans=[]
for i in range(1,n):
  ans.append(lista[i]-lista[i-1])
print(k-max(ans))

k,n=map(int,input().split())
lista=list(map(int,input().split())) 
ans=[]
for i in range(n-1):
  ans.append(lista[i+1]-lista[i])
print(k-max(ans))

k,n=map(int,input().split())
a=list(map(int,input().split()))
a.append(k+a[0])
print(k-max(a))
       

k,n=map(int,input().split())
lista=list(map(int,input().split())) 
ans=[]
for i in range(1,n):
  ans.append(lista[i]-lista[i-1])
print(k-max(ans))

k,n=map(int,input().split())
a=list(map(int,input().split()))
a.append(k+a[0])
b=[]
for i in range(1,n+1):
  b.append(a[i]-a[i-1])
print(k-max(b))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
m, n = map(int, input().split())
nums = list(map(int, input().split()))

a = 0
for i in range(n):
  if i == n-1:
    dif = m - nums[i]
  else:
    dif = nums[i+1] - nums[i]
  a = max(a, dif)
  
print(m-a)



m, n = map(int, input().split())
nums = list(map(int, input().split()))
 
a = 0
for i in range(n):
  if i == n-1:
    dif = m + nums[0] - nums[i]
  else:
    dif = nums[i+1] - nums[i]
  a = max(a, dif)

print(m-a)

Verdicts: Wrong Answer

Accepted
Problem: There is a circular pond with a perimeter of K meters, and N houses around them.  The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.  When traveling between these houses, you can only go around the pond.  Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

Submission attempts (in order):
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = a[n-1] + a[0]
for i in range(n-1):
  ans = min(ans, k - a[i+1] + a[i])
print(ans)

k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = k - a[n-1] + a[0]
for i in range(n-1):
  ans = min(ans, a[i+1] - a[i])
print(ans)

k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = a[n-1] - a[0]
for i in range(n-1):
  ans = min(ans, k - a[i+1] + a[i])
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted