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()))
a = [0] * n
if n==2:
    print(b[0]*2)
else:
    #c = d = 0
    a[0] = b[0]
    for i in range(n-1,-1,-1):
        if i == n-1:
            a[i] = b[i-1]
        elif i == 0:
            #a[0] = min(b[0],b[1])
        else:
            a[i] = min(b[i-1],b[i])
    print(sum(a))

n = int(input())
b = list(map(int,input().split()))
a = [0] * n
if n==2:
    print(b[0]*2)
else:
    #c = d = 0
    a[0] = b[0]
    for i in range(n-1,-1,-1):
        if i == n-1:
            a[i] = b[i-1]
        elif i == 0:
            pass
            #a[0] = min(b[0],b[1])
        else:
            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(int,input().split())

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

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

print(answer)


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

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

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

print(answer)


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(1, N-1):
    print(min(B[i-1], B[i]))
    ans += min(B[i-1], B[i])
print(ans)


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

ans = B[0] + B[-1]
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 = [int(x) for x in input().split()]

print((sum(b)+b[0]+b[-1])//2)

n = int(input())
b = [int(x) for x in 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):
n=int(input())
d=list(map(int,input().split()))
s=[0]*(n-1)

for i in range(1,n-2):
  if d[i]>d[i+1]:
    s[i]+=d[i+1]
  else:
    s[i]+=d[i]
print(d[0]+sum(s)+d[n-2])

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



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):
from sys import stdin,stdout


if __name__=="__main__":

    n=int(stdin.readline())
    n-=1
    b=[int(x) for x in stdin.readline().split()]

    s=b[0]

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

    stdout.write(str(s)+"\0")

    

def maximalValue():
    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

print("test")
print("test")
print("test")
print("test")
print("test")
print("test")
print("test")
print("test")
print("test")
print("test")

n=int(input())
arr=[int(i) for i in input().split()]
ans=0
for i in range(n):
    if i==n-1:
        ans+=arr[-1]
    elif i==0:
        ans+=arr[0]
    else:
        ans+=min(arr[i],arr[i-1])
print(ans)


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())
B=list(map(int,input().split()))
ans=B[0]+B[-1]
for i in range(n-1):
  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):
b = list(map(int,input().split()))
ans = b[0]
for i in range(n - 2):
    
    ans += min(b[i],b[i + 1])

ans += b[-1]
print(ans)

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

ans += b[-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())
B_list = list(map(int,input().split()))
A_list = [0 for i in range(N)]

sum_aaa =0

sum_aaa = B_list[0]

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

sum_aaa += B_list[-1]
print(sum_aaa)


N = int(input())
B_list = list(map(int,input().split()))
A_list = [0 for i in range(N)]

A_list[0] = B_list[0]

for i in range(1,N-1):
    A_list[i] = min(B_list[i],B_list[i-1])

A_list[-1] = B_list[-1]
print(sum(A_list)

N = int(input())
B_list = list(map(int,input().split()))
A_list = [0 for i in range(N)]

A_list[0] = B_list[0]

for i in range(1,N-1):
    A_list[i] = min(B_list[i],B_list[i-1])

A_list[-1] = B_list[-1]
print(sum(A_list))

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 = input()
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-1]))
print(sum(A))

N = int(input())
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-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())
a = input().split()

point = 0

if n == 2:
  point = int(a[0])*2
else:
  for i in range(n-1):
    if i == (n-2):
      point += int(a[i])
    else:
      point += min([int(a[i]),int(a[i+1])])

print(point)

n = int(input())
a = input().split()

point = 0

if n == 2:
  point = int(a[0])*2
else:
  for i in range(n):
    if i == 0:
      point += int(a[0])
    elif i == (n-1):
      point += int(a[i-1])
    else:
      point += min(int(a[i-1]),int(a[i]))
print(point)

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()))
print(B)
A=[]
A.append(B[0])
A.append(B[N-2])

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

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

for i in range(N-2):
    m=min(B[i],B[i+1])
    A.append(m)
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):
# -*- coding: UTF-8 -*-

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

s = b[0]+b[-1]
p = 0


if n >= 2:
    for i in range(1,n-1):
        s += min(b[i],p)
        p = b[i]

print(s)


# -*- coding: UTF-8 -*-

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

s = b[0]+b[-1]
p = b[0]


if n > 2:
    for i in range(1,n-1):
        s += min(b[i],p)
        p = b[i]

print(s)


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()))
k = B[0]+B[-1]
A = [ min(B[i],B[i+1] for i in range (N-2) ]
C = sum(k + A)
print(C)


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


N = int(input())
B = list(map(int, input().split()))
k = B[0]
for i in range(1, N-1):
    if B[i] < B[i-1]:
        k += B[i]
    else:
        k += B[i-1]
print(k)


N = int(input())
B = list(map(int, input().split()))
k = B[0]
for i in range(1, N):
    if B[i] < B[i-1]:
        k += B[i]
    else:
        k += B[i-1]
print(k)


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

Verdicts: Runtime Error

Runtime Error

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()))
ans=0
ans+=max(b[0],b[1])
ans+=b[n-2]
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=0
ans+=b[0]
ans+=b[n-2]
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())
li = list(map(int, input().split()))
r = li[0] + li[-1]
for i, j in enumerate(li):
    if j != li[-1]:
        r += min(j, li[i + 1])
        print(j, li[i + 1])
print(r)


n = int(input())
li = list(map(int, input().split()))
r = li[0] + li[-1]
for i, j in enumerate(li):
    if j != li[-1]:
        r += min(j, li[i + 1])
        print(j, li[i + 1])
print(r)


n = int(input())
li = list(map(int, input().split()))
r = li[-1]
for i, j in enumerate(li):
    if j != li[-1]:
        r += min(j, li[i + 1])
print(r)


n = int(input())
li = list(map(int, input().split()))
r = li[0] + li[-1]
for i, j in enumerate(li):
    if i != len(li)-1:
        r += min(j, li[i + 1])
print(r)


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):
 = int(input())
b = list(map(int, input().split()))
if n == 2:
    print(b[0] * 2)
else:
    res = [0] * n
    for i in range(n-2):
        if b[i] < b[i+1]:
            res[i] = b[i]
            res[i+1] = b[i]
        else:
            res[i+1] = b[i+1]
    if b[-2] < b[-1]:
        res.append(b[-1])
    else:
        res[-1] = b[-1]
        res.append(b[-1])
    print(sum(res))


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


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[0]

print(len(b))
if len(b) >= 2:
    for i in range(1,len(b)):
        if b[i-1]<b[i]:
            sum+=b[i-1]
        else:
            sum+=b[i]
        
sum+=b[i]
        
print(sum)

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

sum =b[0]

if len(b) >= 2:
    for i in range(1,len(b)):
        if b[i-1]<b[i]:
            sum+=b[i-1]
        else:
            sum+=b[i]
        
sum+=b[-1]
        
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())
arr = list(map(int,input().split()))

solution = [0]*n
for i in range(n):
    if i == 0:
        solution[i] = arr[i]
    elif i == n-1:
        solution[i] = arr[i-1]
    else:
        solution[i] = min(arr[i-1], arr[i])

print(solution)
print(sum(solution))

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

solution = [0]*n
for i in range(n):
    if i == 0:
        solution[i] = arr[i]
    elif i == n-1:
        solution[i] = arr[i-1]
    else:
        solution[i] = min(arr[i-1], arr[i])

print(sum(solution))

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):
a=int(input())
li = list(map(int,input().split()))
li.reverse()
ans=0
ans+=li[0]
for i in range(len(li)-1):
	ans+=min(li[i],li[i+1])
print(ans)

a=int(input())
li = list(map(int,input().split()))
li.reverse()
ans=0
ans+=li[0]
for i in range(len(li)-1):
	ans+=min(li[i],li[i+1])
ans+=li[len(li)-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 = np.array(input().split(), dtype=uint)[::-1]

et = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1
print(ret)

import numpy as np
N = int(input())
B = np.array(input().split(), dtype=int)[::-1]

ret = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1
print(ret)


import numpy as np
N = int(input())
B = np.array(input().split(), dtype=int)[::-1]

et = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1
print(ret)


import numpy as np
N = int(input())
B = np.array(input().split(), dtype=int)[::-1]

ret = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1
print(ret)

N = int(input())
B = np.array(input().split(), dtype=int)[::-1]

et = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1
print(ret)

import numpy as np
N = int(6)
B = np.array('0 153 10 10 23'.split(), dtype=int)[::-1]

ret = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1

ret += B[-1]
print(ret)

import numpy as np
N = int(input())
B = np.array(input().split(), dtype=int)[::-1]

ret = 0

ret += B[0]

i = 0
while i < N-2:
    ret += B[i] if B[i] < B[i+1] else B[i+1]
    i+=1

ret += B[-1]
print(ret)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

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 maximal():
    query = input().split()
    B = query[1]
    B = B.split()
    B = [int(i) for i in B]
    # length of values is N
    # any number more or equals than 0
    result = []

    result.append(B[0])

    for i in range(0, len(B) - 1):
        # if value is same put in first one
        compared = B[i]
        if B[i + 1] <= compared:
            result.append(B[i + 1])
        else:
            result.append(B[i])

    result.append(B[len(B) - 1])
    return sum(result)


print(maximal())

def maximal():
    query = input().split('\n')
    B = query[1]
    B = B.split()
    B = [int(i) for i in B]
    # length of values is N
    # any number more or equals than 0
    result = []
 
    result.append(B[0])
 
    for i in range(0, len(B) - 1):
        # if value is same put in first one
        compared = B[i]
        if B[i + 1] <= compared:
            result.append(B[i + 1])
        else:
            result.append(B[i])
 
    result.append(B[len(B) - 1])
    return sum(result)
 
 
print(maximal())

def maximal():
    N = int(input())
    B = input()
    B = B.split()
    B = [int(i) for i in B]
    # length of values is N
    # any number more or equals than 0
    result = []
 
    result.append(B[0])
 
    for i in range(0, len(B) - 1):
        # if value is same put in first one
        compared = B[i]
        if B[i + 1] <= compared:
            result.append(B[i + 1])
        else:
            result.append(B[i])
 
    result.append(B[len(B) - 1])
    return sum(result)
 
 
print(maximal())

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())
a = list(map(int, input().split()))
ans  = min(a[-1] , a[-2] if n>2 else a[-1])
for i in range(n-1):
    ans += min(a[len(a) - 1 - i] , a[len(a) - 2 - i])
    print(min(a[len(a) - 1 - i] , a[len(a) - 2 - i]))
    
print(ans)

n = int(input())
a = list(map(int, input().split()))
ans  = min(a[-1] , a[-2] if n>2 else a[-1])
for i in range(n-1):
    ans += min(a[len(a) - 1 - i] , a[len(a) - 2 - i])
   # print(min(a[len(a) - 1 - i] , a[len(a) - 2 - i]))
    
print(ans)

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

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):
from sys import stdin,stdout


if __name__=="__main__":

    n=int(stdin.readline())
    b=[int(x) for x in stdin.readline().split()]
    b.append(1000000)

    s=b[0]

    for i in range(n-1):
        if b[i]>b[i+1]:
            s+=b[i+1]
        else:
            s+=b[i]
    stdout.write(str(s)+"\0")
    


from sys import stdin,stdout


if __name__=="__main__":

    n=int(stdin.readline())
    b=[int(x) for x in stdin.readline().split()]
    b.append(1000000)

    s=b[0]

    for i in range(n-1):
        if b[i]>b[i+1]:
            s+=b[i+1]
        else:
            s+=b[i]
    stdout.write(str(s)+"\0")
    


import math

length = int(input())
array = str(input()).split(" ")
for index in range(len(array)):
    array[index] = int(array[index])
narray = []
narray.append(array[0])
for index in range(1, len(array)):
    narray.append(min(array[index-1],array[index]))
narray.append(array[-1])
sum = 0
for element in narray:
    sum += element
print(sum)


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()))

A = [0] * n

if n == 2:
  A[0] = A[1] = B[0]
elif n == 3:
  A[0] = B[0]
  A[1] = min(B[0], B[1])
  A[-1] = B[-1]
elif n > 3:
  A[0] = B[0]
  A[-1] = B[-1]
  
  for i in range(1, n-1):
    A[i] = min(B[i-1], B[i])


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

A = [0] * n

if n == 2:
  A[0] = A[1] = B[0]
elif n == 3:
  A[0] = B[0]
  A[1] = min(B[0], B[1])
  A[-1] = B[-1]
elif n > 3:
  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: 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())
array = map(int, input().split())
sum = 0
 
for (i = 0; i < num; i++):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i]
      else:
        sum += array[i-1]
    else:
      sum += array[i-1]
        
print(sum)

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for (i = 0; i < num; i++):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i]
      else:
        sum += array[i-1]
    else:
      sum += array[i-1]
        
print(sum)

num = int(input())
array = map(int, input().split())
sum = 0
 
for (i = 0; i < num; i++):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i-1]
      else:
        sum += array[i]
    else:
      sum += array[i-1]
        
print(sum)

num = int(input())
array = map(int, input().split())
sum = 0
 
for i in range(num):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i]
      else:
        sum += array[i-1]
    else:
      sum += array[i-1]
        
print(sum)

num = int(input())
array = map(int, input().split())
sum = 0

for (i = 0; i < num; i++):
	if i == 0:
      sum += i
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i]
      else:
        sum += array[i-1]
    else:
      sum += array[i-1]
        
print(sum)
      
        
    
  

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i-1]
      else:
        sum += array[i]
    else:
      sum += array[i-1]
        
print(sum)

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += array[i]
	else if i < (num-1):
		if array[i] > array[i-1]:
			sum += array[i-1]
		else:
			sum += array[i]
	else:
		sum += array[i-1]
        
print(sum)

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += array[i]
	elif i < (num-1):
		if array[i] > array[i-1]:
			sum += array[i-1]
		else:
			sum += array[i]
	else:
		sum += array[i-1]
        
print(sum)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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 = input()
B = input().split(" ")
A = [0]*int(N)

B = list(map(int,B))
total = 0


A[0] = B[0]

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

A[int(N)-1] = B[int(N)-2]
print(A)
for i in range(int(N)):
    total = A[int(i)] + total

print(total)


N = input()
B = input().split(" ")
A = [0]*int(N)

B = list(map(int,B))
total = 0


A[0] = B[0]

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

A[int(N)-1] = B[int(N)-2]
#print(A)
for i in range(int(N)):
    total = A[int(i)] + total

print(total)


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()))[::-1]

ans = B[0]

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 = 0

for i in range(n-2):
  ans += min(B[i],B[i+1])
ans += B[0]+ B[-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.append(100010)
a = []
a.append(b[0])

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

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

b.append(100010)
a = 0
a += b[0]

for i in range(1,n):
  a += (min(b[i], b[i-1]))
           
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 = [int(i) for i in input().split()][::-1]
#  N = 6
#  B = [0, 153, 10, 10, 23]
#  N = 3
#  B = [2, 5]
ans = 0
ans += B[1]  # A[1]
for i in range(0, N - 1):
    ans += min(B[i - 1], B[i])
print(ans)


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


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()))
a = [0] * n
for i in range(0,n-1):
    a[i] = min(b[i-1],b[i])
#a[0] = a[1]
a[-1] = b[-1]
print(a)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
a[0] = b[0]
a[-1] = 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().split())
a=[0]*n
b=list(map(input().split()))
a[0]=b[0]
a[n-1]=b[n-2]

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

print(sum(a))  
  


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

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

print(sum(a))  
  

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

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().split()))
a[0]=b[0]
a[n-1]=b[n-2]
ans=0

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

print(sum(a))


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 = []
for i in range(n-1):
    a.append(min(b[i:n-1]))
print(sum(a))

n = int(input())
b = list(map(int, input().split()))
a = []
a.append(b[0])
for i in range(n-2):
  a.append(min(b[i],b[i+1]))
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):
#Maximal Value

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

sum = B[0]

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


#Maximal Value

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

if N > 2:
    sum = B[0] + B[N-2]

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



#Maximal Value

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

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

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


#Maximal Value

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

sum = B[0]

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

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


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())
b = list(map(int, input().split()))

a = [0]*n

if n == 2:
  print( 2* b[0])
  exit()

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

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

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

a = [0]*n

if n == 2:
  print( 2* b[0])
  exit()

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

a[0] = b[0]  
a[n-1] = b[n-2]
    
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 = [int(i) for i in input().split()]
a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
print(b)
if n==2:
  print(sum(a))
  exit()
i=0
while i<n-1:
  a[i]=min(b[i-1],b[i])
  i+=1
print(sum(a))

n = int(input())
b = [int(i) for i in input().split()]
a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
if n==2:
  print(sum(a))
  exit()
i=1
while i<n-1:
  a[i]=min(b[i-1],b[i])
  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())
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):
  A[i]=min(B[i-1],B[i])
print(sum(A))

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

N=int(input().split())
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):
  A[i]=min(B[i-1],B[i])
print(sum(A))

N=int(input().split())
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):
  A[i]=min(B[i-1],B[i])
print(sum(A))

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-1):
  A[i]=min(B[i-1],B[i])
print(sum(A))

Verdicts: Wrong Answer

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):
def Input():
    return mapt(int, input().split(" "))

def main():
    n = int(input())
    b = Input()
    data = 0
    for i in range(n-1):
        if i == 0:
            data += b[i]
            continue
        data += min(b[i], b[i-1])
    data += b[-1]
    print(data)
main()

def mapt(fn, *args):
    return tuple(map(fn, *args))

def Input():
    return mapt(int, input().split(" "))

def main():
    n = int(input())
    b = Input()
    data = 0
    for i in range(n-1):
        if i == 0:
            data += b[i]
            continue
        data += min(b[i], b[i-1])
    data += b[-1]
    print(data)
main()

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
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i], b[i+1])
print(ans)

n = int(input())
b = list(map, input().split())
print(sum(b) + b[0])

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

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):
def main(N, X):
    def calc_cost(p):
        return sum((x-p)**2 for x in X)

    return min(map(calc_cost, range(max(X) + 1)))


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = main(N, X)
    print(ans)


N = int(input())
B = [10**6] + list(map(int, input().split())) + [10**6]
print(sum([min(b1, b2) for b1, b2 in zip(B[:-1], B[1:])]))


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):
# C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
A = [10**6]*N

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

print(A)


# C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
A = [10**6]*N

A[0] = B[0]
A[1] = B[0]
for i in range(1,N-1):
    if A[i] >= B[i]:
        A[i] = B[i]
        A[i+1] = B[i]
    else:
        A[i+1] = 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):
# -*- coding: utf-8 -*-


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

    for i in range(len(b) - 1):
        if b[i] < b[i+1]:
            b[i + 1] = b[i]
        print(b)

    result = sum(b) + b[n - 2]
    print(result)


if __name__ == "__main__":
    main()


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


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

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

    print(result)


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 = [int(i) for i in str(input()).split(" ")]
a = [0] * (n)

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

print(a)

n = int(input())
b = [int(i) for i in str(input()).split(" ")]
a = [0] * (n)

for i in range(n - 1):
  # b[i] >= max(a[i], a[i+1])
  if i == 0:
    a[i] = b[i]

  if i == n - 1 - 1:
    a[i + 1] = b[i]
  else:
    a[i + 1] = 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())

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

a[0]=b[0]
a[n-1]=b[n-2]

for i in range(1, n-1):
  if b[i] >= b[i-1]:
    a[i] = b[i-1]
  else:
    a[i] = b[i]

c = 0

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

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-1):
	if b[i]>=b[i-1]:
		a[i]=b[i-1]
	else:
		a[i]=b[i]
s = 0
for i in range(n):
	s += a[i]
	
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):
N = int(input())
B = [int(i) for i in input().split()]

if N == 2:
  print(N*B)
else:
  for i in B:
    if B[i] > B[i+1]:
      A[i] = B[i]
      A[i+1] = B[i]
    else:
      A[i] = B[i]
      A[i+1] = B[i+1]

x = 0
for x in A:
  x = x + A
print(x)

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

A =[]
if N == 2:
    print(N*B[0])
    sys.exit()
else:
    if B[1] >= B[0]:
      A.append(B[0])
      A.append(B[0])
    else:
      A.append(B[0])
      A.append(B[1])
    for i in range(1,len(B)-1):
        if B[i+1] >= B[i]:
          A.append(B[i])
        else:
          A.append(B[i+1])
 
x = 0
for y in A:
  x = x + y
print(x+B[-1])

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):
#coding:utf-8
n = int(input())
b = list(map(int, input().split()))

a = []

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

#print(a)
print(sum(a))

#coding:utf-8

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

a = []

a.append(b[0])


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


a.append(b[n-2])
#print(a)
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 = [int(i) for i in input().split()]

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

A[N - 1] = max(B[N-3],B[N - 2])
print(sum(A))

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

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

A[N - 1] = B[N - 2]
print(sum(A))

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

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

A[N - 1] = B[N-2]

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()))
a = b[0]
for i in range(n-1):
    a += min(b[i-1],b[i])
a += b[n-2]
print(a)

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

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

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):
def check():
    N = int(input())
    B = [int(i) for i in input().split(' ')]

    total = B[0]
    for i in range(N):
        total += B[i]
    print(total)

check()

N = int(input())
B = list(map(int,input().split()))
total = B[0] + B[N-2]

for i in range(1,N-1):
    total += min(B[i], B[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):
List=[list(map(int,input().split())) for i in range(2)]

c=[0]*(len(List[1])-1)

for i in range(len(List[1])-1):
  c[i]=min(List[1][i],List[1][i+1])

d=sum(c)+List[1][-1]

print(d)

n = int(input())
lis = list(map(int,input().split()))
ans = lis[0] + lis[-1]
for i in range(n-2):
    ans += min(lis[i],lis[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())
B = list(map(int, input().split()))

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

if n == 2:
    asum += B[-1]

print(asum)


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

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

print(asum)


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

B_MAX = 100000
N = int(input().strip())
B = input().strip().split()


B = [B_MAX + 1] + [int(b) for b in B] + [B_MAX + 1] 


for i in range(1, N + 1): 
    sum += min(B[i-1], B[i]) # A[i] <= min(B[i-1], B[i])

print(sum)


B_MAX = 100000
N = int(input().strip())
B = input().strip().split()


B = [B_MAX + 1] + [int(b) for b in B] + [B_MAX + 1] 

sum = 0
for i in range(1, N + 1): 
    sum += min(B[i-1], B[i]) # A[i] <= min(B[i-1], B[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())
b = list(map(int,input().split()))

a = list()
ans = 0
a.append(b[0])

for i in range(n-2):
  a.append(b[i])
  if(b[i+1]<b[i]):
    a.pop(i)
    a.append(b[i+1])

j = max(b[n-2],b[n-3])
a.append(j)

for i in range(n):
  ans += a[i]



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

a = list()
ans = 0
a.append(b[0])

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

a.append(b[-1])

for i in range(n):
  ans += a[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 = [b[0], b[n-1]]
for i in range(n-2):
    a.append(min(b[i:i+2]))
print(sum(a))

n = int(input())
b = list(map(int, input().split()))
a = [b[0], b[n-2]]
for i in range(n-2):
    a.append(min(b[i:i+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):
# Author : prayushd
# Language : Python

import re
import os
import sys
from math import ceil, inf
from fractions import gcd
from queue import Queue
from collections import defaultdict, Counter, deque
from bisect import bisect, insort, bisect_left, bisect_right

mod = int(1e9)+7
input = sys.stdin.readline

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [inf]*n
	for i in range(n-1):
		ans[i] = min(ans[i], arr[i])
		ans[i+1] = min(ans[i+1], arr[i])
	# print(ans)
	print(sum(ans))


if __name__ == '__main__':
	main()

# Author : prayushd
# Language : Python

import re
import os
import sys
from math import ceil
from fractions import gcd
from queue import Queue
from collections import defaultdict, Counter, deque
from bisect import bisect, insort, bisect_left, bisect_right

mod = int(1e9)+7
input = sys.stdin.readline

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [inf]*n
	for i in range(n-1):
		ans[i] = min(ans[i], arr[i])
		ans[i+1] = min(ans[i+1], arr[i])
	print(sum(ans))


if __name__ == '__main__':
	main()

n = int(input())
arr = list(map(int, input().split()))
ans = [999999999]*n
for i in range(n-1):
  ans[i] = min(ans[i], arr[i])
  ans[i+1] = min(ans[i+1], arr[i])
  # print(ans)
  print(sum(ans))

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


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted