TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

def A(N,B):
   sum = B[0] + B[N]
   for i in range(N-1):
       sum += min(B[i],B[i+1])
   print(sum)

if __name__='__main__':
   A(N,B)

N = int(input())
B = list(map(int,input().split()))
 
def A(N,B):
   sum = B[0] + B[N-2]
   for i in range(N-2):
       sum += min(B[i],B[i+1])
   print(sum)
 
if __name__=='__main__':
   A(N,B)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

for n in range(1, N):
    if S[n-1] == 'R' and S[n] == 'R':
        count += 1
    elif S[n-1] == 'L' and S[n] == 'L':
        count += 1

count = count + 2*K
ans = min(count, N-1)
print(ans)

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

a = 0

a += B[0]
a += B[N-2]

for n in range(N):
    if n == 0 or n == N-1:
        pass
    else:
        a += min(B[n-1], B[n])

print(a)



Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

list_A = [0]*n

list_A[0] = B[0]
list_A[i-1] = B[i-2]
for i in range(1:n-2):
    list_A[i] = max(B[i],B[i+1])

print(sum(list_A))




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

list_A = [0]*n

list_A[0] = B[0]
list_A[n-1] = B[n-2]
for i in range(1,n-1):
    list_A[i] = min(B[i-1],B[i])

print(list_A)
print(sum(list_A))




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

list_A = [0]*n

list_A[0] = B[0]
list_A[n-1] = B[n-2]
for i in range(1,n-2):
    list_A[i] = min(B[i],B[i+1])

print(list_A)
print(sum(list_A))




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

list_A = [0]*n

list_A[0] = B[0]
list_A[n-1] = B[n-2]
for i in range(1,n-1):
    list_A[i] = min(B[i-1],B[i])

print(sum(list_A))




Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):

A = [0]*(len(B)+1)

A[0] = B[0]
for i in range(len(B)):
    if A[i]>=B[i]:
        A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))

N = int(input())
B = list(map(int, input().split()))
A = [0]*(len(B)+1)

A[0] = B[0]
for i in range(len(B)):
    if A[i]>=B[i]:
        A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

ans = 0


def mini(x, y):
    if x > y:
        return y
    else:
        return x


for i in range(n):
    if i == 0:
        ans += b[0]
    if i == n-1:
        ans += b[n-2]
    else:
        ans += mini(b[i-1], b[i])

print(ans)


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

ans = 0


def mini(x, y):
    if x > y:
        return y
    else:
        return x


for i in range(n):
    if i == 0:
        ans += b[0]
    elif i == n-1:
        ans += b[n-2]
    else:
        ans += mini(b[i-1], b[i])

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
sum = 0
for i in range(N):
    if i == 0:
        sum += list_B[i]
#         print('i == 0')
#         print('i=', i, 'sum=', sum)
    elif i == N-1:
        sum += list_B[i-1]
        print('i == N-1')
#         print(list_B[i-1])
#         print('i=', i, 'sum=', sum)
    else:
        if (list_B[i] >= list_B[i-1]):
            sum += list_B[i-1]
        else:
            sum += list_B[i]
#         print('i=', i, 'sum=', sum)
print(sum)

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

sum = 0
for i in range(N):
    if i == 0:
        sum += list_B[i]
#         print('i == 0')
#         print('i=', i, 'sum=', sum)
    elif i == N-1:
        sum += list_B[i-1]
#         print('i == N-1')
#         print(list_B[i-1])
#         print('i=', i, 'sum=', sum)
    else:
        if (list_B[i] >= list_B[i-1]):
            sum += list_B[i-1]
        else:
            sum += list_B[i]
#         print('i=', i, 'sum=', sum)
print(sum)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

num = [b[0]]

for i in range(1, n - 1):
  if(b[i] <  b[i - 1]):
    num[-1] = b[i]
    num.append(b[i])
  else:
    num.append(b[i])

num.append(b[0])

print(num)
print(sum(num))


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

num = [b[0]]

for i in range(1, n - 1):
  if(b[i] <  b[i - 1]):
    num[-1] = b[i]
    num.append(b[i])
  else:
    num.append(b[i])

num.append(b[0])

print(sum(num))


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

res = bs[0]
for i in range(n - 2):
	res += min(bs[i], bs[i + 1])
	print(res)
	
res += bs[-1]

print(res)

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

res = bs[0]
for i in range(n - 2):
	res += min(bs[i], bs[i + 1])
res += bs[-1]

print(res)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

A_list = []
for i, B in enumerate(B_list):
    if not A_list:
        A_list.append(B)
        A_list.append(B)
        print(B, B)
    elif i < len(B_list)-1:
        if B > B_list[i+1]:
            A_list.append(B_list[i+1])
        else:
            A_list.append(B)
    else:
        A_list.append(B)
    print(A_list)
print(sum(A_list))

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

A_list = []
for i, B in enumerate(B_list):
    if not A_list:
        if len(B_list) > 1 and B > B_list[i+1]:
            A_list.append(B)
            A_list.append(B_list[i+1])
        else:
            A_list.append(B)
            A_list.append(B)
    elif i < len(B_list)-1:
        if B > B_list[i+1]:
            A_list.append(B_list[i+1])
        else:
            A_list.append(B)
    else:
        A_list.append(B)
print(sum(A_list))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):

def main():
    n = int(input())
    b = list(map(int, input().split()))

    a = [0]*n

    for i,e in enumerate(b):
        if i == 0:
            a[0] = b[0]
        else:
            a[i] = min(b[i-1], b[i])

    a[-1] = b[-1]
            # if a[i] >= a[i+1] and e <= b[i-1]:
            #     a[i] = e
            # else:
            #     a[i+1] = e

    print(a)

if __name__ == '__main__':
    main()


def main():
    n = int(input())
    b = list(map(int, input().split()))

    a = [0]*n

    for i,e in enumerate(b):
        if i == 0:
            a[0] = b[0]
        else:
            a[i] = min(b[i-1], b[i])

    a[-1] = b[-1]
            # if a[i] >= a[i+1] and e <= b[i-1]:
            #     a[i] = e
            # else:
            #     a[i+1] = e

    print(sum(a))

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
B=list(map(int,input().split()))
B.append(0)
A=[min(B[i],[i+1]) for i in range(n)]
print(sum(A))


n=int(input())
B=list(map(int,input().split()))
B.append(float('inf'))
A=[min(B[i],B[i+1]) for i in range(n-1)]
print(sum(A))

N=int(input())
B=input().split()
B=[int(n) for n in B]
A=[]
A.append(B[0])
last=0
for i in range(N-2):
    last=B[i]
    if last>B[i+1]:
        A.append(B[i+1])
    else:
        A.append(last)
    last=B[i+1]
A.append(last)
if N>2:
    print(sum(A))
else:
    print(sum(B)*2)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n = int(input())
  *b, = map(int, input().split())
  
  a=[]
  for i in range(1,n-1):
    a+=[min(b[i],b[i-1])]
  a+=[b[-1]]
    
  print(sum(a))


if __name__ == '__main__':
  solve()

def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

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

  print(a)


if __name__ == '__main__':
  solve()

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))
a = [0] * n

a[0] = b[0]
a[n-1] = b[n-2]
for i in range(1,n-2):
    if b[i-1] <= b[i] <= b[i+1]:
        a[i] = b[i-1]
        a[i+1] = b[i]
    elif b[i-1] >= b[i] >= b[i+1]:
        a[i] = b[i]
        a[i+1] = b[i+1]
    elif b[i-1] < b[i] > b[i+1]:
        a[i] = b[i-1]
        a[i+1] = b[i+1]
    else:
        a[i] = b[i]
        a[i+1] = b[i]

sum = 0
for i in range(n):
    sum += a[i]
print(sum)

n = int(input())
b = list(map(int, input().split()))
a = [0] * n

a[0] = b[0]
if n >= 4:
    a[n-1] = b[n-2]
    for i in range(1,n-2):
        if b[i-1] <= b[i] <= b[i+1]:
            a[i] = b[i-1]
            a[i+1] = b[i]
        elif b[i-1] >= b[i] >= b[i+1]:
            a[i] = b[i]
            a[i+1] = b[i+1]
        elif b[i-1] < b[i] > b[i+1]:
            a[i] = b[i-1]
            a[i+1] = b[i+1]
        else:
            a[i] = b[i]
            a[i+1] = b[i]
elif n == 3:
    a[0] = b[0]
    a[1] = min(b[0], b[1])
    a[2] = b[1]
elif n == 2:
    a[0] = b[0]
    a[1] = b[0]

sum = 0
for i in range(n):
    sum += a[i]
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

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

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = [0] + list(map(int,input().split()))
A = [0,B[1]]
for i in range(2,N):
    A.append(B[i-1])
    if A[i] > B[i]:
        A[i] = B[i]
A.append(B[N-1])
print(B[1:])
print(A[1:])
print(sum(A))


N = int(input())
B = [0] + list(map(int,input().split()))
A = [0,B[1]]
for i in range(2,N):
    A.append(B[i-1])
    if A[i] > B[i]:
        A[i] = B[i]
A.append(B[N-1])
print(sum(A))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

cnt = B[0] + B[-1]

for i in range(0, n-2)
    cnt += min(B[i], B[i+1])

print(cnt)


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

cnt = B[0] + B[-1]

for i in range(0, n-2):
    cnt += min(B[i], B[i+1])

print(cnt)


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

l = [B[0]]
for i in range(1,N-1):
    print(i)
    l.append(min(B[i-1], B[i]))
l.append(B[-1])

print(sum(l))

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

l = [B[0]]
for i in range(1,N-1):
    l.append(min(B[i-1], B[i]))
l.append(B[-1])

print(sum(l))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B =  [int(i) for i in input().split()]

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-2):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] >= B[i+1]:
        A[i] = B[i-1]

if B[N-2] > B[N-1]:
    A[N-2] = B[N-3]
        
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

if N > 2:
    for i in range(1, N-1):
        A[i]   = B[i]
        A[i+1] = B[i]
        if B[i] > B[i+1]:
            A[i] = B[i-1]

    for i in range(N):
        ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-1):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] > B[i+1]:
        A[i] = B[i-1]
    
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-2):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] > B[i+1]:
        A[i] = B[i-1]
    
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 

for i in range(1, N-2):
    A[i]   = B[i]
    A[i+1] = B[i]
    if B[i] >= B[i+1]:
        A[i] = B[i-1]


        
for i in range(N):
    ans = ans + A[i]

print(ans)

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

A = [0] * N
sub= [0] * N
ans = 0

A[0] = B[0]
A[-1] = B[-1] 


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

A[0] = B[0]
A[-1] = B[-1] 
A[N-2] = min(B[N-2], B[N-3])

for i in range(N):
    ans = ans + A[i]

print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())

B = list(map(lambda x:int(x), input().split()))

ans = B[0]

for i in range(1, N-1):
  ans += min(B[i-1], B[i])

  
if len(B) != 1:
  ans += B[-2]
else:
  ans += B[0]
print(ans)

N = int(input())

B = list(map(lambda x:int(x), input().split()))

ans = B[0]

for i in range(1, N-1):
  ans += min(B[i-1], B[i])

  
if len(B) != 1:
  ans += B[-1]
else:
  ans += B[0]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))
b = b[::-1]
a = []
cont0 = False
a.append(b[0])
if len(b) == 1:
	print(2*b[0])
	quit() 
if b[0] > b[1]:
	a.append(b[1])
	a.append(b[1])
elif b[0] == b[1]:
	a.append(b[0])
	a.append(b[0])
elif b[0] < b[1]:
	a.append(b[0])
	a.append(b[1])
if len(b) == 2:
	print(sum(a))
	quit()
for i in range(2,n-1):
	if not cont0
		if b[i-2] > b[i-1]:
			if b[i-1] > b[i]:
				a[-1] = b[i]
				a.append(b[i])
			elif b[i-1] == b[i]:
				a.append(b[i])
			else:
				a.append(b[i])
		elif b[i-2] == b[i-1]:
			if b[i-1] > b[i]:
				a[-1] = b[i]
				a.append(b[i])
			elif b[i-1] == b[i]:
				a.append(b[i])
			else:
				a.append(b[i])
		elif b[i-2] < b[i-1]:
			if b[i-1] > b[i]:
				a[-1] = 0
				a.append(0)
				cont0 = True
			elif b[i-1] == b[i]:
				a.append(b[i])
			else:
				a.append(b[i])
	else:
		if b[i-1] < b[i]:
			a.append(b[i])
		else:
			a.append(0)
		cont0 = False

print(sum(a))



n = int(input())
b = list(map(int, input().split()))
c = []
c.append(b[0])
for i in range(1,n-1):
	c.append(min(b[i-1], b[i]))
c.append(b[-1])
print(sum(c))

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

ans = b[0] + b[-1]
for i in range(n-2):
    ans += min(b[i], b[i+1])
ans

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

ans = b[0] + b[-1]
for i in range(n-2):
    ans += min(b[i], b[i+1])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
def solve(inp):
    N = int(inp.readline().strip())
    B = list(map(int, inp.readline().strip().split(' ')))

    A = [0 for i in range(N)]

    A[N - 1] = B[N - 2]
    for i in range(N - 2, 0, -1):
        A[i] = min(B[i - 1], B[i])
    A[0] = B[0]
    print(A)

    return str(sum(A))


def test(s):
    from io import StringIO
    print(solve(StringIO(s)))


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    # test('3\n2 5')
    # test('2\n3')
    # test('6\n0 153 10 10 23')
    main()


def solve(inp):
    N = int(inp.readline().strip())
    B = list(map(int, inp.readline().strip().split(' ')))

    A = [0 for i in range(N)]

    A[N - 1] = B[N - 2]
    for i in range(N - 2, 0, -1):
        A[i] = min(B[i - 1], B[i])
    A[0] = B[0]
    # print(A)

    return str(sum(A))


def test(s):
    from io import StringIO
    print(solve(StringIO(s)))


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    # test('3\n2 5')
    # test('2\n3')
    # test('6\n0 153 10 10 23')
    main()


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(n)]
a[0] = b[0]
a[1] = b[0]
a[n-1] = b[n-2]
for i in range(1,n-1):
    a[i] = b[i-1]
    if a[i] > b[i]:
        a[i] = b[i]
print(a)
    

n = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(n)]
a[0] = b[0]
a[1] = b[0]
a[n-1] = b[n-2]
for i in range(1,n-1):
    a[i] = b[i-1]
    if a[i] > b[i]:
        a[i] = b[i]
print(sum(a))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)

ans = 0
for i in range(N-1):
  if i == 0: ans += B[0]
  elif i == N-2: ans += B[N-2]
  else: ans += min(B[i-1], B[i])
    
print(ans)

N = int(input())
B = list(map(int, input().split()))
 
# A_1 <= B_1
# A_2 <= min(B_1, B_2)
# A_3 <= min(B_2, B_3)
# A_(N-1) <= min(B_(N-2), B_(N-1))
# A_N <= B_(N-1)
# ans = B_1 + min(B_1, B_2) + ... + min(B__(N-2), B_(N-1)) + B_(N-1)
 
ans = B[0] + B[N-2]
for i in range(1, N-1):
  ans += min(B[i-1], B[i])

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
B=list(map(int,input().split(' ')))
A=[0]*n
A[0]=B[0]
A[-1]=B[-1]
for i in range(1,n-2):
        A[i+1]=min(B[i],B[i+1])
print(sum(A))

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

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

B=[]
for i in range(N-1):
    B.append(min(A[i],A[i+1]))
B.append(A[-1])

print(sum(B))

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

A = []

for i in range(N):
	if i == 0:
		A.append(B[0])
	elif 1 <= i <= N-2:
		A.append(min(B[i],B[i-1]))
	else:
		A.append(B[-1])

print(sum(A))

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int, input().split()))
b_rev = b[::-1]
ans = 0
mem = 0
l = []
for i in range(n-2):
    if b_rev[i] >= b_rev[i+1]:
        print(b_rev[i])
        ans += b_rev[i]
        mem = b_rev[i]
        #l.append(b_rev[i])
    else:
        ans += mem
        b_rev[i+1] = b_rev[i]
        #l.append(mem)
ans += b_rev[-1]*2
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

B.reverse()
result = [B[0]]
for i, e in enumerate(B):
    if i < len(B) - 1:
        result.append(min(B[i], B[i+1]))
    else:
        result.append(B[i])
print(result, sum(result))

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

# B.reverse()
result = [B[0]]
for i, e in enumerate(B):
    if i < len(B) - 1:
        result.append(min(B[i], B[i+1]))
    else:
        result.append(B[i])
print(sum(result))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

A=B[0]+B[N-2]
for i in range(0,N-1):
    A+=min(B[i],B[i-1])
    
print(A)

N=int(input())
B=list(map(int,input().split()))
B.append(1000000)
A=0

for i in range(0,N):
    A+=min(B[i],B[i-1])
    
print(A)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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


if N == 2:
    print(B[0]*2)

else:
    A=[]
    for i in range(N-1):
        A.append(min(B[i-2],B[i-1]))
        print(A)

    A.append(B[-1])
    print(A)
    print(sum(A))

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

if N == 2:
    print(B[0]*2)
else:
    res = 0
    for i in range(N-2):
        res += min(B[i],B[i+1])
    res += B[0] + B[-1]
    print(res)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N=int(input())
B = list(map(int,input().split()))
A = [B[0]]+[min(B[i-1],B[i]) for i in range(N-1)]+[B[-1]]
print(A)


N=int(input())
B = [int(i) for i in input().split()]
A = [B[0]]+[min(B[i-1],B[i]) for i in range(N-1)]+[B[-1]]
print(sum(A))


N=int(input())
B = list(map(int,input().split()))
A = [B[0]]+[min(B[i-1],B[i]) for i in range(N-1)]+[B[N-2]]
print(A)

N=int(input())
B = [int(i) for i in input().split()]
A = [B[0]] + [min(B[i-1],B[i]) for i in range(1,N-1)]+[B[-1]]
print(sum(A))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))



n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))



n = int(input())
A = [None for i in range(n)]
B = list(map(int, input().split()))
A[0] = B[0]
A[-1] = B[-1]
 
for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
print(sum(A))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

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

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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


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


Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

# print(N)

output=0

for i in range(N):
   print("i",i)
   if (i==0):
      A[i]=B[i]
   elif(i==N-1):
      print("last",B[i-1])
      A[i]=B[i-1]
   else:
      if(B[i-1]<=B[i]):
         A[i]=B[i-1]
      else:
         A[i]=B[i]



print(sum(A))





N = int(input())
A = [0]*(N)
B = list(map(int, input().split()))

# print(N)

output=0

for i in range(N):
   # print("i",i)
   if (i==0):
      A[i]=B[i]
   elif(i==N-1):
      # print("last",B[i-1])
      A[i]=B[i-1]
   else:
      if(B[i-1]<=B[i]):
         A[i]=B[i-1]
      else:
         A[i]=B[i]



print(sum(A))





Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())

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

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

for i in range(n-1):
  if(a[i] > a[i+1]):
    a[i] = a[i+1]
    
sum = 0
for i in range(n):
  sum += a[i]
  
print(sum)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    d=a[i]
    x+=c[d-1]
print(x)


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

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
def main():
    n = int(input())
    B = input()
    B = B.split()
    B = [int(i) for i in B]
    s = 0
    for i in range(0, n-1):
        if i == 0:
            s += B[0]
        else:
            s += min(B[i - 1], B[i])
    s += B[-1]
    return s

main()

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

ans = arr[0]+arr[N-1]
for i in range(1,N-1,1):
   ans += min(arr[i],arr[i-1])
   
print(ans)


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

ans = arr[0]+arr[N-2]
for i in range(1,N-1,1):
   ans += min(arr[i],arr[i-1])
   
print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

A = []

if N>2 :
    for i in range(N-2):
        if B[i]>B[i+1]:
            A.append(B[i+1])
        else :
            A.append(B[i])

    A.append(A[0])
    A.append(B[N-2])


if N==2:
    A.append(B[0])
    A.append(B[0])


print(A)


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

A = []

if N>2 :
    for i in range(N-2):
        if B[i]>B[i+1]:
            A.append(B[i+1])
        else :
            A.append(B[i])

    A.append(A[0])
    A.append(B[N-2])


if N==2:
    A.append(B[0])
    A.append(B[0])


print(A)


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

A = []

i=0
while i<N-2:
    if B[i]>B[i+1]:
        A.append(B[i+1])
    else :
        A.append(B[i])
    i+=1

A.append(B[i])
A.append(B[0])


print(sum(A))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=(b[i+1]-b[i])
print(x+y)

n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=b[i+1]-b[i]
print(int(x+y))


n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-1):
  if b[i]>b[i+1]:
    y+=b[i+1]-b[i]
print(x+y)
  

n=int(input())
b=list(map(int,input().split()))
x=sum(b)+b[0]
y=0
for i in range(0,n-2):
  if b[i]>b[i+1]:
    y+=b[i+1]-b[i]
print(x+y)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
b = list(map(int,input().split()))
a = [b[0]]

for i in range(n - 1):
    a.append(min(b[i],b[i+1]))

a.append(b[-1])
print(sum(a))

n = int(input())
b = list(map(int,input().split()))
a = [b[0]]

for i in range(n - 1)
    a.append(min(b[i],b[i+1]))

a.append(b[-1])
print(sum(a))

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int, input().split()))
A = [B[0], B[-1]]
C = [min(B[i],B[i+1]) for i in range(N-2)]
ans = sum(A+C)


N = int(input())
B = list(map(int, input().split()))
A = [B[0], B[-1]]
C = [min(B[i],B[i+1]) for i in range(N-2)]
ans = sum(A+C)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

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

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

c =[]

c.append(b[0])

for i in range(1,n-1):
	c.append(min(b[i-1], b[i]))

c.append(b[n-2])
print(c)
print(sum(c))

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

c =[]

c.append(b[0])

for i in range(1,n-1):
	c.append(min(b[i-1], b[i]))

c.append(b[n-2])

print(sum(c))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

a.append(b[0])
for i in range(1,n-1) :
  if b[i-1] < b[i] :
    a.append(b[i-1])
  else :
    a.append(b[i])
a.append(b[n-2])  
print(a)
print(sum(a))

n=int(input())
b=list(map(int,input().split()))
a=[]

a.append(b[0])
for i in range(1,n-1) :
  if b[i-1] < b[i] :
    a.append(b[i-1])
  else :
    a.append(b[i])
a.append(b[n-2])  
print(sum(a))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N=int(input())

B= list(map(int,input().split()))

sum=0
for i in range(len(B)+1):
    if i==len(B)-1:
        sum+=B[i]
        break

    if B[i]<B[i+1]:
        sum+= B[i]
    else:
        sum+=B[i+1]

print(sum)

N=int(input())

B= list(map(int,input().split()))

sum=0
for i in range(len(B)):
    #print(i)
    if i==0:
        sum+=B[i]
    elif B[i-1]<B[i]:
        sum+=B[i-1]
    else:
        sum+=B[i]
    

sum+=B[len(B)-1]
print(sum)



Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int, input().split()))
B.append(10 ** 5 + 1)
ans = 0
for i in range(N - 1):
  ans += min(B[i], B[i + 1])
  
print(ans)

from collections import deque
N = int(input())
B = deque(map(int, input().split()))
B.append(10 ** 5 + 1)
B.appendleft(10 ** 5 + 1)
ans = 0
for i in range(N):
  ans += min(B[i], B[i + 1])
  
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

cout = 0
maxint,minint = 0,0
cout += list1[0]
for i in range(n-1):
    if minint > list1[i]:
        for j in range(i):
            if list1[j] > list1[i]:
                list1[j] = list1[i]
    minint = list1[i]
maxint = 0
"""
for i in range(n-1):
    if list1[i] > maxint:
        maxint = list1[i]
        cout += maxint
    else:
        cout += maxint
"""
cout += list1[0]
for i in range(n-1):
    cout += list1[i]
print(cout)

n = int(input())
a = input()
list1 = list(map(int,a.split()))

cout = 0
maxint,minint = 0,0
cout += list1[0]
for i in range(n-1):
    if minint > list1[i]:
        for j in range(i):
            if list1[j] > list1[i]:
                list1[j] = list1[i]
    minint = list1[i]
maxint = 0
cout += list1[0]
for i in range(n-1):
    if list1[i] > maxint:
        maxint = list1[i]
        cout += maxint
    else:
        cout += maxint

print(cout)

n = int(input())
a = input()
list1 = list(map(int,a.split()))

list2 = []
list2.append(list1[0])
for i in range(n):
    list2.append(min(list1[(n-1)-i:]))
print(sum(list2))

n = int(input())
list1 = list(map(int,input().split()))
cout = list1[-1]
min_int = list1[-1]
for i in range(n-3,-1,-1):
    cout += min(list1[i:i+2])

cout += list1[0]

print(cout)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n, *b = map(int, open(0).read().split())
a = [0]*n
b += float("inf")
for i in range(n):
  a[i] = min(b[i-1], b[i])
print(sum(a))

n, *b = map(int, open(0).read().split())
a = [0]*n
b.append(float("inf"))
for i in range(n):
  a[i] = min(b[i-1], b[i])
print(sum(a))

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

sum = b[n-2] + b[0]
for i in range(n-2):
    print(i,b[i],b[i+1])
    sum += min(b[i],b[i+1])
 
print(sum)

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

sum = b[n-2] + b[0]
for i in range(n-2):
    #print(i,b[i],b[i+1])
    sum += min(b[i],b[i+1])
 
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
N = int(input())
B = list(map(int,input().split()))
ins = 0
count = 0
for i in range(N):
  if i == 0:
    count += B[i]
  if i > 0 and B[i-1] > B[i]:
    count += B[i]
  elif i > 0 and B[i-1] <= B[i]:
    count += B[i-1]
print(count)

N = int(input())
B = list(map(int,input().split()))
ins = 0
count = 0
for i in range(N-1):
  if i == 0:
    count += B[i]
  if i > 0 and B[i-1] > B[i]:
    count += B[i]
  elif i > 0 and B[i-1] <= B[i]:
    count += B[i-1]
count += B[i]
print(count)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

ans = bs[0]
for i in range(1, n-2):
    ans += min(bs[i], bs[i+1])

ans += bs[-1]

print(ans)


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

ans = bs[0]
for i in range(0, n-2):
    ans += min(bs[i], bs[i+1])

ans += bs[-1]

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
num = int(input())

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

a=[arr[0]]
for i in range(1,num-1):
    a0 = min(arr[i],arr[i-1])
    print(a0)
    a.append(a0)
a.append(arr[-1])

print(sum(a))

num = int(input())

arr = list(map(int,input().split()))
arr.append(arr[num-2])
a=[]
for i in range(1,num):
    a0 = min(arr[i],arr[i-1])

    a.append(a0)

a.append(a[-1])

print(sum(a))

num = int(input())

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

a=[arr[0]]
for i in range(1,num-1):
    a0 = min(arr[i],arr[i-1])

    a.append(a0)
a.append(arr[-1])

print(sum(a))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
n = int(input())
a = [int(x) for x in input().split()]

b = 0
bef = 0

for i in a:
  #print("bef1=", bef)
  if i >= bef:
    b = b + i
    #print("b1=", b)
  else:
    b = b - bef + i + i
    #print("b2=", b)
  bef = i
  #print("bef2=", bef)

print(b)

  

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

b = a[0]
bef = 0

for i in a:
  #print("bef1=", bef)
  if i >= bef:
    b = b + i
    #print("b1=", b)
  else:
    b = b - bef + i + i
    #print("b2=", b)
  bef = i
  #print("bef2=", bef)

print(b)


Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

n = int(input())
b = list(map(int, input().split()))
s=0
if n==2:
  print(b[0]*2)
else:
  if(b[0]<b[1]):
  	s = b[0]*2+b[-1]
  else:
  	s = b[0]+b[1]+b[-1]
  for i in range(1,n-2):
  	s+=min(b[i],b[i+1])
    
  print(s)

Verdicts: Runtime Error

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

Submission attempts (in order):
#C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
print(B)
A = [B[0]]
for i in range(1,N-1):
    print(A)
    if B[i] > B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))

#C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
A = [B[0]]
for i in range(1,N-1):
    if B[i] > B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))

Verdicts: Wrong Answer

Accepted
Problem: There is an integer sequence A of length N whose values are unknown.  Given is an integer sequence B of length N-1 which is known to satisfy the following:  B_i \geq \max(A_i, A_{i+1})  Find the maximum possible sum of the elements of A.

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

ans = B[-1]

for i in range(N-2):
    ans += min(B[i],B[i+1])

if N == 2:
    ans += B[0]


print(ans)

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

ans = sum(B)*2

for i in range(N-2):
    ans -= max(B[i],B[i+1])


print(ans)

Verdicts: Wrong Answer

Accepted