Problem:


Score : 400 points

Problem Statement

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.

Constraints

All values in input are integers.

3 \leq N \leq 10^5-1

N is an odd number.

0 \leq A_i \leq 10^9

The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print N integers representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.

Sample Input 1

3
2 2 4

Sample Output 1

4 0 4

If we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:

Dam 1 should have accumulated \frac{4}{2} + \frac{0}{2} = 2 liters of water.

Dam 2 should have accumulated \frac{0}{2} + \frac{4}{2} = 2 liters of water.

Dam 3 should have accumulated \frac{4}{2} + \frac{4}{2} = 4 liters of water.

Sample Input 2

5
3 8 7 5 5

Sample Output 2

2 4 12 2 8

Sample Input 3

3
1000000000 1000000000 0

Sample Output 3

0 2000000000 0



Sample input:
3
2 2 4


Sample output:
4 0 4

Submission status: Wrong Answer

Solution code:
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

x_0 = 0

for i in range(N):
    if (i % 2) == 0:
        x_0 += List[i]
    else:
        x_0 -= List[i]

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(result_x)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
a = 0
for i in range(N):
  a += A[i] * (-1) ** i
b = a
print(a, end = " ")

for i in range(1, N-1):
  b = 2 * A[i-1] - b
  print(b, end = " ")

print(2 * A[N-2] - a)

Submission status: Wrong Answer

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(1,len(A)):
  X.append((A[i]-X1by2/2)*2)

print(" ".join(repr(int(e)) for e in X))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = [-1]*N

total = sum(A)/2
total2 = sum(A[1::2])
for i in range(N//2):
    X[i*2] = int(total - total2)
    X[i*2+1] = int(A[i*2]-X[i*2])
    total -= A[i*2]
    total2 -= A[i*2]
X[-1] = int(A[-1] - X[0])

ans = ''
for i in range(N):
    ans += str(X[i]*2) + ' '

print(ans[:-1])

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()

# 山1の雨量は、左右のダムの大きい方
# 山1の雨量は、左右の山を見て候補値を絞り込む
# 例えば左右にそれぞれ6と4溜まっている場合、自分を0,2,4降った可能性を検討する
# ダムxの水量を見て、ありうる候補を見つける
# 最小値から見ると速いかも

min_dam = min(A)
min_dam_idx = A.index(min_dam)
tmp_A = A[min_dam_idx:] + A[:min_dam_idx]
# min_damの横の山1つの雨量を決めれば、そこから時計まわりに雨量を決めていけば自ずと決まる
for i in range(0, min_dam+1):
    is_correct = True
    current_idx = 0
    yamas = []
    while is_correct and len(yamas) < N:
        # iは現在の山からどれだけとるか
        if yamas == []:
            #山iは2倍の雨量
            yamas.append(i*2)
            yamas.append((min_dam - i) * 2)
            if yamas[-1]/2 > tmp_A[current_idx+1]:
                # 矛盾
                is_correct = False
            current_idx += 1
        else:
            # 既にやまのシミュレーションが始まっている場合
            yamas.append((tmp_A[current_idx]-yamas[-1]/2)*2)
            if len(yamas) == N:
                yamas = yamas[N-min_dam_idx:] + yamas[0:N-min_dam_idx]
                yamas = [int(yama) for yama in yamas]
                if yamas[-1]/2 + yamas[0]/2 == A[-1]:
                    # 正解
                    print(*yamas)
                    exit()
                else:
                    #  print('wrong', yamas)
                    is_correct = False
            elif yamas[-1]/2 > tmp_A[current_idx+1]:
                is_correct = False
            current_idx += 1
    else:
        if is_correct:
            # 正解
            print(*yamas)
            exit()

Submission status: Wrong Answer

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

s = sum(A)

for i in range(N):
    if i != N - 1:
        result = s - 2 * A[i + 1]
    else:
        result = s - 2 * A[0]
    print(result)

Submission status: Wrong Answer

Solution code:
import math

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

l,r = 0,max(A)
a = r // 2
while True:
  b = math.ceil(a / 2)
  m = A[-1] - b
  if b - A[-1] > 0:
#    print("Q")
    r = a
  else:
    for i in range(N-1):
#      print(a,b,m,A[i],(l,r))
      if b - A[i] > 0:
#        print("W")
        r = a
        break
      b = (A[i] - b)
    else:
      if b > m:
#        print("E")
        r = a
      elif b < m:
#        print("R")
        l = a
      else:
#        print("wow")
        b = a
        for i in range(N):
          print(b,end=" ")
          b = ((A[i] - b // 2) * 2)
        exit()
        
  a = (l + r) // 2

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int, input().split()))

R1 = sum(A_list) - 2 * sum(A_list[i] for i in range(1,N,2))

Ri_list = [0] * N

Ri_list[0] = R1

for i in range(1,N):
    print(A_list[i-1])
    Ri_list[i] = A_list[i-1] * 2 - Ri_list[i-1]

for item in Ri_list:
    print(item, end=' ')

Submission status: Wrong Answer

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(1,len(A)):
  X.append((A[i]-X1by2/2)*2)

print(" ".join(repr(e) for e in X))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(zz) for zz in input().split()]
B = [0]*N

tmp = 0
for i in range(N):
    if i%2 == 0:
        tmp += A[i]*2
    else:
        tmp -= A[i]*2

B[0] = int(tmp/2)
for i in range(1,N):
    B[i] = A[i-1]*2 - B[i-1]

[print(i, end='') for i in B]

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
h = [0]*N
for i in range(N):
  if i%2==0:
    h[0] = h[0] + a[i]
  else:
    h[0] = h[0] - a[i]
for i in range(N-1):
  h[i+1] = 2*(a[i]-h[i])
print(*h)

Submission status: Wrong Answer

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

for i in range(N):
    s = sum(A)
    if i != N - 1:
        s -= 2 * A[i + 1]
    else:
        s -= 2 * A[0]
    print(s)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())
A = LI()

mountains = ["a" for i in range(N)]
last = sum(A)//2
for i in range(0,N//2+1,2):
    last -= A[i]

mountains[-1] = last

for i in reversed(range(N-1)):
    if mountains[i] == "a" and mountains[i+1] != "a":
        mountains[i] = A[i] - mountains[i+1]

for i in range(N):
    print(mountains[i]*2,end=" ")
print()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

B = []
for i in range(N - 1):
    tmp = []
    for j in range(N):
        if j == i:
            tmp.append(1)
        elif j == i + 1:
            tmp.append(1)
        else:
            tmp.append(0)
    B.append(tmp)
tmp = [0] * N
tmp[0] = 1
tmp[-1] = 1
B.append(tmp)

L = np.array(B)
R = np.array(A)
print(L)
print(R)

X = np.linalg.solve(L, R * 2)
ans = ''
for i in range(N - 1):
    ans += str(int(X[i])) + ' '
ans += str(int(X[-1]))
print(ans)

Submission status: Wrong Answer

Solution code:
def d_rain_flows_into_dams(N, A):
    ans = [0] * N
    for i in range(N):
        prev, cur = (i - 1 + N) % N, i
        a, b = A[prev], A[cur]
        if a % 2 == 1 and b % 2 == 1:
            ans[i] = 2
            A[prev] -= 1
            A[cur] -= 1
        else:
            ans[i] = min(a, b) * 2
            A[prev] -= min(a, b)
            A[cur] -= min(a, b)
    return ' '.join(map(str, ans))

N = int(input())
A = [int(i) for i in input().split()]
print(d_rain_flows_into_dams(N, A))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
List = []
List.append(sum(a[0::2])-sum(a[1::2]))
for i in range(n-1):
	List.append(2 * a[i]-List[i])
print(List)

Submission status: Wrong Answer

Solution code:
import sys
p = [[int(t) for t in r.split(' ')] for r in sys.stdin.read().split('\n') if r != '']
N = p[0][0]
A = p[1]
for i in range(1, A[0]+1):
    M = [0] * N
    z = i
    for j in range(0, N):
        if (A[j] - z) > A[(j + 1) % N]:
            break
        M[(j + 1) % N] += (A[j] - z) * 2
        z = A[j] - z
        if j == N - 1:
            print(' '.join([str(x) for x in M]))
            quit()

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
diff = []
for i in range(N):
    left = i
    right = (i+1)%N
    d = A[right]-A[left]
    diff.append(d)
#print(diff)
B = [0 for i in range(N)]
for i in range(N):
    if i%2 == 0:
        if i < N-2:
            B[i+2] = B[i]+diff[i]
        else:
            pass
for i in range(N):
    if i%2 == 1:
        if i == 1:
            B[1] = B[-1]+diff[-1]
        elif i < N-2:
            B[i+2] = B[i]+diff[i]
        else:
            pass
SUMb = sum(B)
SUMa = sum(A)
k = ((SUMa//2)-SUMb)//N
for i in range(N):
    print(2*(k+B[i]),end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

y = sum(A * ([1, -1]*(len(A)//2)+[1]))//2

answer = [y]
AA = y
for i in range(N-1):
    AA = -AA + A[i]
    answer.append(AA)
answer = np.array(answer)*2

print(answer)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
input=lambda : sys.stdin.readline().rstrip()

n=int(input())
a=list(map(int,input().split()))
l,r=0,min(a[0],a[-1])*2
ans=-1
while l+2<r:
    mid = ((l+r)//2)*2
    tmp=a[0]
    fl=mid
    xx=a[-1]
    for i in range(n):
        if i==n-1 and tmp-fl//2==0:
            ans=mid
            break
        elif i==n-1 and tmp-fl//2>0:
            l=mid//2
            if l%2:
                l-=1
            break
        if tmp-fl//2<0:
            r=mid//2
            if r%2:
                r+=1
            break
        else:
            fl=(tmp-fl//2)*2
            if i==0:
                xx-=fl//2
            tmp=a[i]
            if i==n-2:
                tmp==xx
    if ans!=-1:
        break
if ans==-1:
    ans=l

ans_a=[]
for i in range(n):
    ans_a.append(ans)
    ans=(a[i]-ans//2)*2
print(*ans_a)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

B=np.array([[1 if j==i%N or j==(i+1)%N else 0 for j in range(N)]for i in range(N)])
A=2*np.dot(np.linalg.inv(B),A)
print(" ".join(map(str,A.T)))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

d_sum = np.sum(a)
d_sum_even = np.sum(a[::2])
d_sum_odd = np.sum(a[1::2])
print(d_sum_even, d_sum_odd)

result = []
for i in range(n):
    idx = [(i+j+1)%n for j in range(0, n-1, 2)]
    sum = np.sum(a[idx])
    result.append(d_sum - sum*2)
    
print(" ".join(map(str, result)))

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
diff = []
for i in range(N):
    left = i
    right = (i+1)%N
    d = A[right]-A[left]
    diff.append(d)
#print(diff)
B = [0 for i in range(N)]
for i in range(N):
    if i%2 == 0:
        if i < N-2:
            B[i+2] = B[i]+diff[i]
        else:
            pass
for i in range(N):
    if i%2 == 1:
        if i == 1:
            B[1] = B[-1]+diff[-1]
        elif i < N-2:
            B[i+2] = B[i];diff[i]
        else:
            pass
SUMb = sum(B)
SUMa = sum(A)
k = ((SUMa//2)-SUMb)//N
for i in range(N):
    print(2*(k+B[i]),end=" ")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
input=lambda : sys.stdin.readline().rstrip()

n=int(input())
a=list(map(int,input().split()))
l,r=0,min(a[0],a[-1])*2
ans=-1
while l+2<r:
    mid = ((l+r)//2)*2
    tmp=a[0]
    fl=mid
    xx=a[-1]
    for i in range(n):
        if i==n-1 and tmp-fl//2==0:
            ans=mid
            break
        elif i==n-1 and tmp-fl//2>0:
            l=mid//2
            if l%2:
                l-=1
            break
        if tmp-fl//2<0:
            r=mid//2
            break
        else:
            fl=(tmp-fl//2)*2
            if i==0:
                xx-=fl//2
            tmp=a[i]
            if i==n-2:
                tmp==xx
    if ans!=-1:
        break
if ans==-1:
    ans=l

ans_a=[]
for i in range(n):
    ans_a.append(ans)
    ans=(a[i]-ans//2)*2
print(*ans_a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

for i in range(a[0]*2+1):
    b = [i]
    for j in range(1,n):
        c = a[j-1]*2-b[-1]
        if not (c<0):
            b.append(c)
        else:
            break
    if len(b)==n and (b[0]+b[-1] == a[-1]*2):
        print(b)
        exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = [-1 for _ in range(N)]

total = sum(A)/2
for i in range(N//2):
    X[i*2] = int(total - sum(A[i*2+1::2]))
    X[i*2+1] = int(A[i]-X[i*2])
    total -= A[i*2]
X[-1] = int(A[-1] - X[0])

ans = ''
for i in range(N):
    ans += str(X[i]*2) + ' '

print(ans[:-1])

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    Mt = [0]*(N+1)

    def is_ok(x,Mt):
        Mt[0]=x
        for i in range(N):
            Mt[i+1] = int(2* (A[i] - (Mt[i]/2)))
            if Mt[i+1] < 0 or Mt[i+1]%2 == 1:
                return False
        return Mt[0] == Mt[-1]

    mini = min(A) + 1
    for i in reversed(range(mini)):
        if is_ok(i,Mt):
            break
    
    """
    ng = 2*(10**9)
    ok = -1
    while abs(ok - ng) > 1:
        mid=(ok + ng) // 2
        print(mid)
        if is_ok(mid,Mt):
            ok=mid
        else:
            ng=mid
    """
    print(*Mt[:-1])
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

l = -2
r = 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return False
    
while abs(r - l) > 1:
    if r % 2 == 1:
        r -= 1
    if l % 2 == 1:
        l -= 1
    if l > r:
        break
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
if r % 2 == 1:
    r -= 1
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

l = -2
r = 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return False
    
while abs(r - l) > 1:
    if r % 2 == 1:
        r -= 1
    if l % 2 == 1:
        l -= 1
    if l > r:
        break
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC133 D

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]

n = int(input())
a = LI()
mi = min(a)
index = a.index(mi)

r = 0
while r <= mi*2:
    rain = [0]*n
    rain[0] = r
    for i in range(index+1,n+index):
        res = a[i-index] - (rain[i-index-1])//2
        if res < 0:
            break
        rain[i-index] = res*2
    if rain[-1]//2 + rain[0]//2 == a[index]:
        break
    r += 2
ans = []
for i in range(n):
    ans.append(str(rain[i-index-1]))
print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

l = -1
r = 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return n % 2 == 0
    
while abs(r - l) > 1:
    # if r % 2 == 1:
    #     r -= 1
    # if l % 2 == 1:
    #     l += 1
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Submission status: Wrong Answer

Solution code:

N=int(input())

a=list(map(int,input().split()))
sum=0
b=[]
for i in range(N):
    b.append(2*a[i])
    sum+=a[i]

ans=[]
a_1=0
for j in range((N-1)//2):
    a_1-=b[2*(j+1)-1]

a_1=sum+a_1
ans.append(a_1)
for i in range(N-1):
    ans.append(b[i]-ans[i])
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

l = -1
r = 10

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return n % 2 == 0
    
while abs(r - l) > 1:
    # if r % 2 == 1:
    #     r -= 1
    # if l % 2 == 1:
    #     l += 1
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
List=list(map(int,input().split()))
a = 0
b = []
for i in range(N//2):
    a += List[2*i] - List[2*i+1]
b.append(a + List[N-1])
for i in range(N-1):
    b.append(2*(List[i]-b[i]//2))
print(b)

Submission status: Wrong Answer

Solution code:
import sys, math

readline = sys.stdin.readline

N = int(readline())

A = list(map(int, readline().split()))

a0 = sum(A[0:N:2]) - sum(A[1:N:2])
a = [a0]
print(A)
for i in range(1, N):
    ai = A[i - 1] * 2 - a[i - 1]
    a.append(ai)

for ai in a:
    print(ai)

Submission status: Wrong Answer

Solution code:
L = 2*(10**2)
R = 2*(10**5)

if L >= 2019:
    L = L%2019
if R >= 2019:
    R = R%2019

print(L)
print(R)

list = []
if L < R :
  for i in range(L,R):
      for j in range(i+1,R+1):
          list.append(i*j%2019)

else :
  for i in range(0,2018):
    for j in range(i+1,2019):
        list.append(i*j%2019) 

print(min(list))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    ret = [0] * N
    tmp = A[0]
    i = 1
    while i < N - i:
        tmp = A[i] + A[N - i] - tmp
        i += 1
    ret[N // 2 + 1] = tmp
    for i in range(N // 2, -1, -1):
        ret[i] = A[i] * 2 - ret[i + 1]
    for i in range(N // 2 + 2, N):
        ret[i] = A[i] * 2 - ret[i - 1]
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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])

Submission status: Wrong Answer

Solution code:
N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
Mt = [0] * N

for i in range(N):
    Mt[0] += A[i] * (-1) ** i

for i in range(1, N):
    Mt[i] = 2 * A[i - 1] - Mt[i-1]

print(Mt)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

X=0
for i in range(N):
    if i%2==0:
        X+=A[i]
    else:
        X-=A[i]

print(X)


ANS=[X]

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

print(*ANS)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

coef_mat = np.matrix([[1 if (i == j or i + 1 == j or (i + 1 == N and j == 0)) else 0 for j in range(N) ] for i in range(N)])**(-1)
vec = np.matrix([A]).T
res = coef_mat @ vec

for i in range(N):
    print(int(res[i, 0]) * 2)

Submission status: Time Limit Exceeded

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
ans=[]
S=sum(A)//2
for i in range(N):
    tmp=S
    j=i+1
    for _ in range(N//2):
        tmp-=A[j%N]
        j+=2
    ans.append(2*tmp)
lprint(ans,' ')

Submission status: Time Limit Exceeded

Solution code:

def resolve():
    '''
    code here
    '''

    N = int(input())
    As = [int(item) for item in input().split()]

    def cal(num):
        last_num = 0
        ans_list = [0 for _ in range(N)]
        
        for i in range(N):
            if i == 0:
                last_num = num // 2
                prev_num = num // 2
                ans_list[0] = num
                continue
            
            temp_num = 2 * (As[i-1] - prev_num)
            ans_list[i] = temp_num
            if temp_num < 0:
                return 'too small'
            
            if i == N-1:
                if last_num + temp_num // 2 == As[-1]:
                    return ans_list
                else:
                    return 'too large'

            prev_num = temp_num //2

    R = 2 * max(As[0], As[-1])
    L = 0
    mid = (R + L)//2
    is_search = True
    while is_search:
        flag = cal(mid)
        if flag == 'too large':
            R, mid = mid, ((L+mid)//4)*2
        elif flag == 'too small':
            L, mid = mid, ((R+mid)//4)*2
        else:
            is_search = False

    print(*flag)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

ans = [0 for _ in range(N)]

for i in range(N):
    sign = 1

    for a in A:
        ans[i] += sign * a
        sign *= -1

    t = A.pop(0)
    A.append(t)

print(*ans)

"""
ダム1: 2( a1 - a2 + a3 )
ダム2: 2( a2 - a3 + a1 )
ダム3: 2( a3 - a1 + a2 )
"""

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

a = []
for i in range(N):
  l = [0] * N
  l[i] = 1/2
  if i < N-1:
    l[i+1] = 1/2
  else:
    l[0] = 1/2
  a.append(l)

a = np.array(a)
b = np.array(A)
n = np.linalg.solve(a, b)
ans = []
for i in range(N):
  ans.append(int(n[i]))
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int, input().split()))

def plus_minus(idx):
    ans = [0] * n
    indicator = 1
    for new_i in range(idx, idx + n):
        ans[new_i % n] = indicator
        indicator *= -1
    #print(idx, ans)
    return ans

ans = []
for dam in range(n):
    total = 0
    pm = plus_minus(dam)
    for i, a in enumerate(A):
        total += pm[i] * a
    ans.append(total)

print(*ans, sep=" ")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list([int(x) for x in input().split()])

for i in range(0, A[0] * 2 + 1, 2):
    result = [0] * N
    result[0] = i
    for x in range(N-1, -1, -1):
        if x == N-1:
            r = (A[x] - result[0] // 2) * 2
        else:
            r = (A[x] - result[x+1] // 2) * 2

        if r % 2 != 0 or r < 0:
            break

        if x == 0:
            if r == i:
                print(' '.join([str(x) for x in result]))
                exit()

        result[x] = r

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

left = []
right = []

for key, v in enumerate(A):
    s = [0] * N
    s[key] = 1

    if key+1 == N:
        s[0] = 1
    else:
        s[key+1] = 1
    left.append(s)

    right.append([v])

a = np.matrix(left)
b = np.matrix(right)

result = np.linalg.solve(a, b).flatten().tolist()[0]
print(' '.join([str(int(x) * 2) for x in result]))

Submission status: Time Limit Exceeded

Solution code:
from numpy.linalg import solve

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

l = []
for i in range(N):
    tmp = [0] * N
    tmp[i] = 1
    if i+1 >= N:
        tmp[0] = 1
    else:
        tmp[i+1] = 1
    l.append(tmp)

r = list(map(lambda a: a*2, A))

# print(l)
# print(A)
print(*map(int, solve(l, r)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
R = []

'''A1だけ別個で計算する'''
tmp = 0
for j in range(0, N, 2):
    tmp += A[j]
for k in range(1, N, 2):
    tmp -= A[k]
R.append(tmp)

'''A2~AN'''
for i in range(1, N):
    tmp = 0
    pm = -1
    for j in range(i-1-N, -N-1, -1):  # A[i-1]より手前側
        pm *= -1
        tmp += A[j] * pm
    pm = -1
    for k in range(i, N):  # A[i]より後ろ側
        pm *= -1
        tmp += A[k] * pm
    R.append(tmp)

print(*R)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))



for i in range(0,a[0]*2+1,2):
    ans1 = [i]
    ans2 = [i]
    for j in range(1,n//2+1):
        tmp1 = (a[j-1]-ans1[j-1]//2)*2
        tmp2 = (a[-j]-ans2[j-1]//2)*2
        ans1.append(tmp1)
        ans2.append(tmp2)
    if (ans1[-1]/2 + ans2[-1]/2) == a[n//2]:
        ans2.reverse()
        ans2.pop()
        print(*ans1, end=" ")
        print(*ans2)
        exit()