TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import numpy as np

N = int(input())
A = np.array([int(_) for _ in input().split()])
lis = [([0] * N) for n in range(N)]
for n in range(N - 1):
    lis[n][n] = lis[n][n + 1] = 1
lis[N - 1][0] = lis[N - 1][N - 1] = 1



print(*np.dot(np.linalg.inv(np.array(lis)), A) * 2)

n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

asum=sum(alist)
ans_list=[0]*N
for i in range(N):
  ans_list[i] = asum-2*(alist[(i+1)%N]+alist[(i+3)%N])
  
ans_list_str=map(str,ans_list)  
print(" ".join(ans_list_str))

N=int(input())
alist=list(map(int,input().split()))

asum=sum(alist)
ans_list=[-1]*N

minus_even=sum(alist[1:N:2])
minus_odd=sum(alist[2:N:2])

for i in range(N//2):
  ans_list[2*i] = asum-2*minus_even
  ans_list[2*i+1] = asum-2*minus_odd
  
  minus_even += alist[(2*i+N)%N]-alist[(2*i+1)%N]
  minus_odd += alist[(2*i+N+1)%N]-alist[(2*i+2)%N]
  
ans_list[-1]=asum-2*minus_even
  
ans_list_str=map(str,ans_list)  
print(" ".join(ans_list_str))

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = []
b.append(s - 2*sum(a[1::2]))
for i in range(n-1):
    b.append(2*a[i] - b[i])
print(b)

n = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = []
b.append(s - 2*sum(a[1::2]))
for i in range(n-1):
    b.append(2*a[i] - b[i])
print(' '.join(map(str, b)))

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
ans = np.array(a)

s = (n,n)
M = np.matrix(np.zeros(s))
for i in range(n):
    vec = np.zeros(n)
    vec[i]=1/2
    if i == (n-1):
        vec[0]=1/2
    else:
        vec[i+1]=1/2
    M[i] = vec
ans = (np.linalg.inv(M)*(ans.reshape(-1,1)))
print(' '.join(map(str, ans.T.tolist()[0])))

import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a) - a[-2] - a[0]))

for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]

print(' '.join(map(str, map(int, x))))



import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a) - a[-1]))

for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]
    
print(' '.join(map(str, map(int, x))))



import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a[1::2])))

for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]

print(' '.join(map(str, map(int, x))))


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import numpy as np


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  
N = 10 ** 4
g1 = [1, 1]  
g2 = [1, 1]  
inverse = [0, 1]  計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


n = int(input())
arr = list(map(int,input().split()))
arr = np.array(arr)
A = np.zeros((n,n))

for i in range(n):
    A[i][i] = 0.5
    A[i][i-1] = 0.5

ans = np.linalg.solve(A, arr)

for i in range(n-1):
    print(int(ans[i-1]),end=" ")

print(int(ans[n-1]))





import numpy as np





n = int(input())
arr = list(map(int,input().split()))


#
# if n <= 3:
#     ans = np.linalg.solve(A, arr)
#

#         print(int(ans[i]), end=" ")
#
#     print(int(ans[n - 1]))
# else:

odd = 0
eq = 0
all = [0,0]

for i in range(n):
    if i % 2 == 0:
        eq += arr[i]
        all.append(eq)
    else:
        odd += arr[i]
        all.append(odd)


ans = [0 for i in range(n)]

base = eq-odd
base2 = odd-eq+2*arr[0]
for i in range(n):
    if i %2 ==  0:
        ans[i] = base
        if i == n-1:
            break
        base -= 2*arr[i]
        base += 2* arr[i+1]


    if i %2 ==  1:
        ans[i] =base2
        base2 -= 2*arr[i]
        base2 += 2*arr[i+1]



for i in range(n-1):
    print(ans[i],end=" ")
print(ans[-1])







Verdicts: Runtime Error

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

ans = [0 for _ in range(n)]
sum_rain = sum(a_list)
tmp = sum_rain
for a in a_list[:-1:2]:
    tmp -= a * 2
ans[-1] = tmp
ans[0] = a_list[-1] * 2 - tmp
tmp = ans[0]
for i in range(1, n-1):
    tmp = a_list[i-1] * 2 - tmp
    ans[i] = tmp
print(ans)


n = int(input())
a_list = list(map(int, input().split()))

ans = [0 for _ in range(n)]
sum_rain = sum(a_list)
tmp = sum_rain
for a in a_list[:-1:2]:
    tmp -= a * 2
ans[-1] = tmp
ans[0] = a_list[-1] * 2 - tmp
tmp = ans[0]
for i in range(1, n-1):
    tmp = a_list[i-1] * 2 - tmp
    ans[i] = tmp
print(*ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):

import scipy.linalg as linalg

N = int(input())
solve_arr = [int(i) for i in input().split()]
solve_arr = [i*2 for i in solve_arr]
w_arr = []

for i in range(N):
  arr = [0]*N
  if i == N-1:
    arr[i] = 1
    arr[0] = 1
  else:
    arr[i] = 1
    arr[i+1] = 1
  w_arr.append(arr)
  
LU = linalg.lu_factor(w_arr)
ans = linalg.lu_solve(LU, solve_arr)


for i in ans:
  print(str(int(i)) + " ", end ="")

import numpy as np
import scipy.linalg as linalg

N = int(input())
solve_arr = [int(i) for i in input().split()]

w_arr = []

for i in range(N):
  arr = [0]*N
  if i == N-1:
    arr[i] = 1/2
    arr[0] = 1/2
  else:
    arr[i] = 1/2
    arr[i+1] = 1/2
  w_arr.append(arr)
  
LU = linalg.lu_factor(w_arr)
ans = linalg.lu_solve(LU, solve_arr)


for i in ans:
  print(str(int(i)) + " ", end ="")

from numpy.linalg import solve

N = int(input())
solve_arr = [int(i) for i in input().split()]

w_arr = []

for i in range(N):
  arr = [0]*N
  if i == N-1:
    arr[i] = 1/2
    arr[0] = 1/2
  else:
    arr[i] = 1/2
    arr[i+1] = 1/2
  w_arr.append(arr)
  
ans = solve(w_arr, solve_arr)
for i in ans:
  print(str(int(i)) + " ", end ="")

N = int(input())
dam_arr = list(map(int,input().split()))
mount_arr = []

# calculate 1st mount's rain
rain = 0
for i in range(N):
  if i%2==0:
    rain += dam_arr[i]
  else:
    rain -= dam_arr[i]
    
mount_arr.append(rain)

# caluculate others
for i in range(N-1):
  mount_arr.append(2*dam_arr[i]-mount_arr[-1])

mount_arr=[str(a) for a in mount_arr]
mount_arr=" ".join(mount_arr)
print(mount_arr)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
    A[max_idx] -= b


import numpy as np
N = int(input())
A = [int(i) for i in list(input().split())]
A = np.array(A)

res = np.zeros(len(A))

max_idx = np.argmax(A)

if max_idx - 1 >= 0:
    max_idx -= 1
else:
    max_idx = max_idx + N - 1

a = A[max_idx] // 2 * 4

if max_idx + 1 > N - 1:
    res[0] = a
else:
    res[max_idx + 1] = a
A[max_idx] -= a // 2
    
    
for i in range(N - 1):
    b = A[max_idx]
    res[max_idx] += b * 2
    if max_idx - 1 >= 0:
        max_idx -= 1
    else:
        max_idx = max_idx + N - 1
    A[max_idx] -= b
    
for i in res.astype(np.int64):
    print(i, end=' ')

import numpy as np
N = int(input())
A = [int(i) for i in list(input().split())]
A = np.array(A)

res = np.zeros(len(A))

max_idx = np.argmax(A)

if max_idx - 1 >= 0:
    max_idx -= 1
else:
    max_idx = max_idx + N - 1

a = A[max_idx] // 2 * 4

if max_idx + 1 > N - 1:
    res[0] = a
else:
    res[max_idx + 1] = a
A[max_idx] -= a // 2
    
    
for i in range(N - 1):
    b = A[max_idx]
    res[max_idx] += b * 2
    if max_idx - 1 >= 0:
        max_idx -= 1
    else:
        max_idx = max_idx + N - 1
    A[max_idx] -= b
    
print(res.astype(np.int64))

input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n = int(input())
lst = list(map(int,input().split()))
ans = []
some = 0
for i in range(n):
    some += lst[i]*(((-1)**i))/2
for i in range(n):
    if i == 0:
        ans.append(str(int(some)))
    else:
        ans.append(str(int(lst[i-1]-int(ans[i-1]))))
print(" ".join(ans))

n = int(input())
lst = list(map(int,input().split()))
ans = []
some = 0
for i in range(n):
    some += lst[i]*(((-1)**i))
for i in range(n):
    if i == 0:
        ans.append(str(int(some)))
    else:
        ans.append(str(2*int(lst[i-1]-int(ans[i-1])/2)))
print(" ".join(ans))

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-2):
	b[i+2]=b[i]+(a[i+1]-a[i])*2
sa=(a[-1]-a[-2])*2+b[-2]
for i in range(n//2):
	b[i*2+1]-=sa
hosei=sum(a)-sum(b)
for i in range(n):
	b[i]+=hosei//5
print(*b)

n=int(input())
a=list(map(int,input().split()))
ans=[]
x=0
for i in range(n):
	if i%2==0:
		x+=a[i]
	else:
		x-=a[i]
ans.append(x)
for i in range(n-1):
	x=2*a[i]-x
	ans.append(x)
print(*ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

x1 = sum(A) - 2 * sum(A[1::2])
print(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')

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

x1 = sum(A) - 2 * sum(A[1::2])
print(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')
print()

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

x1 = sum(A) - 2 * sum(A[1::2])
ans = []
ans.append(str(x1))
for i in range(N-1):
    x1 = 2 * A[i] - x1
    ans.append(str(x1))
print(' '.join(ans))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n = int(input())
aa = list(map(int, input().split()))
total_odd = sum(aa[1::2])
total_eve = sum(aa[2::2])
tmp = aa[0] + total_odd - total_eve
last = tmp
for i in range(1,n):
    tmp = 2*aa[i] - tmp
    print(tmp)
print(last)


l, r = map(int, input().split())
if r //2019 > l //2019:
    print(0)
else:
    res = 2018
    for i in range(l%2019, (r+1)%2019):
        for j in range(i+1, (r+1)%2019):
            res = min(res, (i*j)%2019)
    print(res)

l, r = map(int, input().split())
if r //2019 > l //2019:
    print(0)
else:
    res = 2018
    for i in range(l%2019, (r%2019)+1):
        for j in range(i+1, (r%2019)+1):
            res = min(res, (i*j)%2019)
    print(res)


n = int(input())
aa = list(map(int, input().split()))
total_odd = sum(aa[1::2])
total_eve = sum(aa[0::2])
tmp = total_eve - total_odd
outs = [tmp]
for i in range(1,n):
    tmp = 2*aa[i-1] - tmp
    outs.append(tmp)
print(' '.join(list(map(str,outs))))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
N = int(input())
A_s = list(map(int,input().split()))
X_s = []
X_s.append(sum(A_s)-2*sum(A_s[1::2]))
for i,a in enumerate(A_s):
  X_s.append(2*A_s[i]-X_s[i])
print(' '.join(map(str,X_s)))

N = int(input())
A_s = list(map(int,input().split()))
X_s = []
X_s.append(sum(A_s)-2*sum(A_s[1::2]))
for i,a in enumerate(A_s):
  X_s.append(2*A_s[i]-X_s[i])
X_s.pop()
print(' '.join(map(str,X_s)))


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import numpy as np

L, R = list(map(int, input().split()))

if R-L >= 2019:
    print(0)
else:
    tmp = []
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp.append((i * j) % 2019)
    print(min(tmp))


# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])

r = map(str, r)
print(" ".join(r))

Verdicts: Runtime Error

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
N = int(input())
A = input().split()
A = [int(n) for n in A]
print(A)
S = sum(A)
print(S)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])

print(result)

N = int(input())
A = input().split()
A = [int(n) for n in A]
S = sum(A)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)
text = str(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])
    text += " " + str(result[i+1])

print(text)

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

MaxX1=min(A[-1],A[1])*2

for i in range(0,MaxX1+2,2):
    X=[i]*N
    for j in range(N-1):
        X[j+1]=2*A[j]-X[j]
        AJ=[0]*N
        for k in range(N):
            AJ[k-1]=X[k-1]/2+X[k]/2
        if AJ==A:
            print(X)
            exit

n=int(input())
A=list(map(int,input().split()))
X=[0]*n
S=sum(A)
A2=0
for i in range(1,n-1,2):
  A2+=A[i]
X[0]=S-2*A2
for i in range(1,n):
  X[i]=2*A[i-1]-X[i-1]
print(*X)

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i, a in enumerate(A):
        if i != 0:
            X[i] = 2*A[i] - X[i-1]
    return X

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    print(' '.join(map(str, rain_volume(A, N))))


import numpy as np

def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i, a in enumerate(A):
        if i != 0:
            X[i] = 2*A[i] - X[i-1]
    return X

if __name__ == '__main__':
    N = int(input())
    A = deque(map(int, input().split(' ')))

    print(' '.join(map(str, rain_volume(A, N))))

def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i in range(1, N):
        if i != 0:
            X[i] = 2*A[i-1] - X[i-1]
    return X

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    print(' '.join(map(str, rain_volume(A, N))))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
print(a0)
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(ans)


n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(ans)


n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(*ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

s = 1

for i in range(N):
    s = A[i] - s
    # print('A[i]',A[i])
    # print(s)

x = s//2
B = [0]*N

for i in range(N):
    B[i] = x*2
    x = A[i] - x

print(*B)

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

s = 0

for i in range(N):
    s = A[i] - s
    # print('A[i]',A[i])
    # print(s)

x = s//2
B = [0]*N

for i in range(N):
    B[i] = x*2
    x = A[i] - x

print(*B)


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [x]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(x)
    print(ans)


main()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [str(x)]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(str(x))
    print(' '.join(ans))


main()


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import numpy as np

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

C = np.zeros((N, N))

for i in range(N-1):
  C[i][i] = 0.5
  C[i+1][i] = 0.5

C[0][N-1] = 0.5
C[N-1][N-1] = 0.5

Cin = np.linalg.inv(C)
B = np.dot(A , Cin)

print (int(B[0]), end = "")
for i in range(1,N):
  print ( " " + str(int(B[i])), end = "")
  

import numpy as np

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

X = [0]*N
X[0] = sum(A) - 2 * (sum(A[1:N-1:2]))
for i in range(1, N):
  X[i] = 2 * A[i-1] - X[i-1]
print (' '.join(map(lambda x: str(x), X)))

Verdicts: Runtime Error

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
from itertools import*


n,*b=map(int,open(0).read().split())

a1=sum(b[i]*(-1)**(i%2) for i in range(n))

print(a1)

l=[a1]
for i in range(n-1):
    l.append((b[i]-l[-1]//2)*2)
print(*l)

from itertools import*


n,*b=map(int,open(0).read().split())

a1=sum(b[i]*(-1)**(i%2) for i in range(n))


l=[a1]
for i in range(n-1):
    l.append((b[i]-l[-1]//2)*2)
print(l)

n=int(input())
*a,=map(int,input().split())
for i in range(n):
  print((a[i-1]+a[i])//2,end=" ")

from itertools import*


n,*b=map(int,open(0).read().split())

a1=sum(b[i]*(-1)**(i%2) for i in range(n))


l=[a1]
for i in range(n-1):
    l.append((b[i]-l[-1]//2)*2)
print(*l)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    q = a[i]*2 - p
    a3.append(q)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        exit()
    mountain += " "
print(mountain)

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    q = a[i]*2 - p
    a3.append(q)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    q = a[i]*2 - p
    a3.append(q)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    mountain += " "
print(mountain)

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1):
    q = a[i]*2 - p
    a3.append(q)
print(a3)

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(int,lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-sum(a2[1::2]))
    a2.append(a2[0])
    del a2[0]

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Time Limit Exceeded

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

tmp = 0
for i in range(N//2-1):
  tmp += A[2*i]
  
ans = []
if sum(A) > 2*tmp:
  ans.append(sum(A)-2*tmp)
else:
  ans.append(0)
  
for i in range(N):
  ans.append(2*A[i]-ans[-1])
print(*ans)

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

tmp = 0
for i in range(N//2):
  tmp += A[2*i+1]
  
ans = []
if sum(A) > 2*tmp:
  ans.append(sum(A)-2*tmp)
else:
  ans.append(0)
  
for i in range(N-1):
  ans.append(2*A[i]-ans[-1])
print(*ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans)


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans[:-1])


Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
print(sum(a))
print(sum(a[1::2]))
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
# print(sum(a))
# print(sum(a[1::2]))
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

out = [0] * N

for i in range(N) :
    ans = A[i]
    sig = i % 2

    
    for j in range(0,i) :
        ans += (-1)**(j+sig) * A[j]

    
    for j in range(i+1,N) :
        ans += (-1)**(j+sig+1) * A[j]
    out[i] = ans

print('{} '.format(out[-1]), end='')
out.pop()

for o in out :
    print('{} '.format(o), end='')

print('')

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

S = 0
for i, a in enumerate(A):
    S += (-1)**i * a

ans = [0] * N
ans[0] = S
for i, a in enumerate(A[:-1], start=1):
    S *= -1
    S += 2 * a
    ans[i] = S

print(*ans)

Verdicts: Time Limit Exceeded

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import numpy as np
N = int(input())
p = np.array(list(map(int,input().split())))
a0 = 0
for i in range(0,N,2):
    a0 += p[i]
    
for i in range(1,N-1,2):
    a0 -= p[i]
    
ans2 = [a0]*N

for i,one in enumerate(p[1:]):
    ans2[i+1] = 2*p[i] - ans2[i] 

import numpy as np
N = int(input())
p = np.array(list(map(int,input().split())))
a0 = 0
for i in range(0,N,2):
    a0 += p[i]
    
for i in range(1,N-1,2):
    a0 -= p[i]
    
ans2 = [a0]*N

for i,one in enumerate(p[1:]):
    ans2[i+1] = 2*p[i] - ans2[i] 
    
ans_s = ""
for one in ans2:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
t = [0]
for i, a in enumerate(A):
    if i % 2 == 0:
        t.append(a)
    else:
        t.append(-a)
for i in range(N):
    t[i+1] += t[i]
print(t)
for i in range(1, N+1):
    if i % 2:
        print(t[N] - t[i-1] - t[i-1])
    else:
        print(-t[N] + t[i-1] + t[i-1])

N = int(input())
A = list(map(int, input().split()))
t = [0]
for i, a in enumerate(A):
    if i % 2 == 0:
        t.append(a)
    else:
        t.append(-a)
for i in range(N):
    t[i+1] += t[i]
ans = []
for i in range(1, N+1):
    if i % 2:
        ans.append(t[N] - t[i-1] - t[i-1])
    else:
        ans.append(-t[N] + t[i-1] + t[i-1])
print(*ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

for i in range(n):
	r = 0
	for j in range(n):
		k = (i+j)%n
		if j%2 == 0:
			
			r += aList[k]
			#print(aList[k])
		else:
			#print('minus')
			r -= aList[k]
			#print(aList[k])
	print(str(r) ,end=' ')
			
	


n=int(input())
aList=list(map(int,input().split()))
rList = []
r1 = 0
for i in range(n):
	if i%2 == 0:
		r1 += aList[i]
	else:
		r1 -= aList[i]
rList.append(r1)

for i in range(n-1):
	r = (2 * aList[i]) - rList[i]
	rList.append(r)

print(' '.join(map(str, rList)))

Verdicts: Time Limit Exceeded

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
import collections as cl
N = int(input())
water = cl.deque(map(int,input().split()))
sum = sum(water)
ans = []
for i in range(N):
  sum_odd = 0
  sum_even = 0
  for k in range((N+1)//2):
    sum_odd += water[2*k]
  sum_even = sum - sum_odd
  ans.append((sum_odd - sum_even))
  water.rotate(-1)
  
print(*water)
      

import collections as cl
N = int(input())
water = cl.deque(map(int,input().split()))
sum = sum(water)
ans = []
sum_odd = 0
sum_even = 0
for i in range(N):
  if i == 0:
    for k in range((N+1)//2):
      if i == 0:
        sum_odd += water[2*k]
        sum_even = sum - sum_odd
  else:
    xxx = sum_even
    yyy = sum_odd
    sum_odd = xxx + water[-1]
    sum_even = yyy - water[-1]
  ans.append((sum_odd - sum_even))
  water.rotate(-1)
  
print(*ans)

Verdicts: Wrong Answer

Accepted