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]*(len(B)+1)
A[0] = B[0]
A[1] = B[0]
cnt = 0
for i, x in enumerate(B):
    if i != 0:
        A[i + 1] = B[i]
        A[i] = min(A[i], B[i])
        cnt += A[i]
cnt += A[-1]
# print(A)
print(cnt)

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

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

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

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

n = int(input())
alist=list(map(int,input().split()))
print(sum(min(alist[i-1],alist[i],alist[i+1]) for i range(1,n-1))\
      +min(alist[-2],alist[-1])+alist[-1]+min(alist[0],alist[1]))

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

n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)

Verdicts: Wrong Answer

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 = int(input())
b = list(map(in,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())
B = list(map(int, input().split(" ")))
A = B[0]
An = B[0]
C = B[0]
for i in range(len(B)):
  if An <= B[i]:
    C += An
  else:
    C+= B[i]
  An = B[i]

C += An
print(C)

n = int(input())
B = list(map(int, input().split(" ")))
A = B[0]
An = B[0]
C = B[0]
for i in range(1,n-1):
  if An <= B[i]:
    C += An
  else:
    C+= B[i]
  An = B[i]

C += An
print(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()))
if N==2:
    print(B[0]*2)
else:
    A = [0]*N

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


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

A = [0]*N
A[0] = B[0]
for n in range(1,N-1):
    A[n] = min(B[n],B[n-1])
A[N-1] = 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())
bs=list(map(int,input().split()))

a=[0]*n
a[0]=bs[0]
a[n-1]=bs[n-2]

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

print(a)
print(sum(a))


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

a=[0]*n
a[0]=bs[0]
a[n-1]=bs[n-2]

for i in range(1,n-1):
    a[i]=min(bs[i-1],bs[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):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
b_arr = list(map(lambda b: int(b), input().split()))
a_arr = list(range(N))

for n in range(N-1, -1, -1):
    if (n == N-1) or (n == N-2):
        a_arr[N-1] = b_arr[N-2]
        a_arr[N-2] = b_arr[N-2]
    elif b_arr[n+1] >= b_arr[n]:
        a_arr[n+1] = b_arr[n]
        a_arr[n] = b_arr[n]
    else:
        a_arr[n] = b_arr[n]

print(sum(a_arr)

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

N = int(input())
b_arr = list(map(lambda b: int(b), input().split()))
a_arr = list(range(N))

for n in range(N-1, -1, -1):
    if (n == N-1) or (n == N-2):
        a_arr[N-1] = b_arr[N-2]
        a_arr[N-2] = b_arr[N-2]
    elif b_arr[n+1] >= b_arr[n]:
        a_arr[n+1] = b_arr[n]
        a_arr[n] = b_arr[n]
    else:
        a_arr[n] = b_arr[n]

print(sum(a_arr))

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 = []
A.append(B[0])
A.append(B[0])
for i in range(1, N - 2):
  if B[i] < A[i]:
    A[i] = B[i]
  
  if N != 2:
    A.append(B[i])

print(sum(A))
  

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

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);
  
  let cnt = N-1;
  let ret = 0;
  let tmp = 0;
  for(let i=0; i<cnt; i++){
    if(i===0){
      ret += B[i];
      tmp = B[i]
      continue;
    } 

    if(tmp < B[i]){
      ret += B[i];
      ret += tmp - B[i];
    } else {
      ret += B[i];
    }
    tmp = B[i];
  }
  ret += tmp;
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);

  let cnt = N-2;
  let ret = B[0];
  for(let i=0; i<cnt; i++){
    ret += Math.min(B[i], B[i+1])
  }
  ret += B[cnt];
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    B = il()
    ret = B[len(B) - 1] + B[0]
    for n in range(N - 2):
        ret += min(B[n+1], B[n])
    print(ret)


if __name__ == '__main__':
    main()


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())
foods = [int(i) for i in input().split()]
eff = sum([int(i) for i in input().split()])
plus = [int(i) for i in input().split()]
if foods[-1]-2 in plus:
  print(eff + plus[foods[-1]-2])
else:
  print(eff)

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

for i in range(N):
    if i == 0:
        A[i] = B[0]
    else:
        if i < N-1:
            if B[i-1] <= B[i]:
                A[i] = B[i-1]
                A[i+1] = B[i]
            else:
                A[i] = B[i]
                # A[i+1] = B[i+1]
        else:
            A[i] = 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())
a = [int(a) for a in input().split()]
for i in range (n-1):
  aa = min(a[i],a[i+1])
  aaa.append(aa)
print(aaa)

n = int(input())
a = [int(a) for a in input().split()]
aaa=[]
if n==2:
  print(a[0]*2)
else:
  for i in range (n-2):
    aa = min(a[i],a[i+1])
    aaa.append(aa)
  aaa.append(a[n-2])
  print(sum(aaa))

n = int(input())
a = [int(a) for a in input().split()]
aaa=[]
if n==2:
  print(a[0]*2)
else:
  aaa.append(a[0])
  for i in range (1,n-1):
    aa = min(a[i-1],a[i])
    aaa.append(aa)
  aaa.append(a[n-2])
  print(sum(aaa))

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):
As = []

for i in range(N):
    if i == N-1:
        As.append(Bs[i-1])
    elif i == 0:
        As.append(Bs[0])
    else:
        As.append(min([Bs[i-1],Bs[i]]))

print(sum(As))

N = int(input())
Bs = list(map(int, input().split()))
As = []

for i in range(N):
    if i == N-1:
        As.append(Bs[i-1])
    elif i == 0:
        As.append(Bs[0])
    else:
        As.append(min([Bs[i-1],Bs[i]]))

print(sum(As))

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

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

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

n = int(input())
li = list(map(int, input().split()))
a = li[0] + li[n-2]
for i in range(1, n-1):
  a += min(li[i], li[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):
if __name__ == '__main__':
    a = int(input())
    li_1 = list(map(int, input().split()))
    res = []
    for x in range(0, a - 1):
        if x == 0:
            res.append(li_1[x])
        else:
            res.append(min(li_1[x], li_1[x - 1]))
res.append(li_1[-1])
result = 0
for x in res:
    result += x


if __name__ == '__main__':
    a = int(input())
    li_1 = list(map(int, input().split()))
    res = []
    for x in range(0, a - 1):
        if x == 0:
            res.append(li_1[x])
        else:
            res.append(min(li_1[x], li_1[x - 1]))
res.append(li_1[-1])
result = 0
for x in res:
    result += x

print(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 = []
for i in range(N):
  A.append(0)

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

print(A)

N = int(input())
B = list(map(int,input().split()))
A = []
for i in range(N):
  A.append(0)

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

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

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

As = [copy.copy(Bs[0])]
As.extend(copy.copy(Bs))

#print(Bs)
#print(As)

for index, B in enumerate(Bs):
    print(Bs)
    print(As)
    if B < As[index]:
        As[index] = B

#print(As)
print(sum(As))



import copy

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

As = [copy.copy(Bs[0])]
As.extend(copy.copy(Bs))

#print(Bs)
#print(As)

for index, B in enumerate(Bs):
#    print(Bs)
#    print(As)
    if B < As[index]:
        As[index] = B

#print(As)
print(sum(As))



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 = [-1] * N
B = list(map(int, input().split()))

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

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

  A[-1] = B[-1]

  print(sum(A))

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

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

  A[-1] = 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()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0]),B[1])
    exit()
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=max(B[-1],B[-2])
print(total)

N=int(input())
B=list(map(int,input().split()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0]),B[1])
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=max(B[-1],B[-2])
print(total)

N=int(input())
B=list(map(int,input().split()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0])+B[2])
    exit()
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=max(B[-1],B[-2])
print(total)

N=int(input())
B=list(map(int,input().split()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0])+B[1])
    exit()
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=B[-1]
print(total)

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=int(input())

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

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

print(sum(a))


n=int(input())

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

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

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: 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]*2
for i in range(n-2):
    if b[i] > b[i+1]:
        b[i] = b[i+1]
    sum += b[i]
sum += b[-1]
print(sum)


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

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

k = int(input())
b = list(map(int, input().split()))
a = [b[0]]+b
for i in range(len(b)):
	if (a[i]<=b[i]):
		pass
	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 = sum(B)*2
for i in range(N-1):
  if B[i] <= B[i+1]:
    A -= B[i+1]
  else:
    A -= B[i]
print(A)

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

B.sort()
A=[]
A.append([B[0]])

for i in range(N):
    if i>0 && i < N-1 :
        A.append(min(B[i-1],B[i],B[i+1]))
    if i == N-1:
        A.append(B[N-1])
print(sum(A))

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

A=[]
A.append(B[0])
for i in range(0,N-2):
    if i>=1 & i < N-2:
      A.append(min(B[i],B[i+1]))
      
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()))
a = [0 for i in range(N)]

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

a[-1] = b[-1]
            
        
    

print(sum(a))


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

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

a[-1] = b[-1]
            
        
    
print(a)
print(sum(a))


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

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

a[-1] = b[-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())
Bs = list(map(int, input().split()))

As = [ None for _ in range(N) ]

for i in range(N-1):
  i = N - i - 2
  if not As[i+1] or As[i+1] > Bs[i]:
    As[i+1] = Bs[i]
  
  As[i] = Bs[i]
  print(Bs)
  print(As)


print(sum(As))

N = int(input())
Bs = list(map(int, input().split()))
 
As = [ None for _ in range(N) ]

As[0] = Bs[0]
for i in range(1, N):  
  As[i] = min(Bs[i-1], Bs[i])

print(sum(As))

N = int(input())
Bs = list(map(int, input().split()))
 
As = [ None for _ in range(N) ]

As[0] = Bs[0]
for i in range(1, N-1):  
  As[i] = min(Bs[i-1], Bs[i])

As[-1] = Bs[-1]

print(sum(As))

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

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

ans += B[N-2]

print(ans)

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

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

ans += B[N-2]

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[N-2]

print(ans)


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):
import sys
readline = sys.stdin.buffer.readline

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

B.append(float('inf'))

mins = [min(B[0]]

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

print(sum(mins))

import sys
readline = sys.stdin.buffer.readline

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

B.append(float('inf'))

mins = [min(B[0])]

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

print(sum(mins))

import sys
readline = sys.stdin.buffer.readline

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

B.append(float('inf'))

mins = [B[0]]

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

print(sum(mins))

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


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

N = int(input())

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


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

for i in range(len(B)):
    if i == 0:
        A[i] = B[i]
    else:
        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())
bb=list(map(int,input().split()))
aa=[0]*n
for i in range(n-1):
  aa[i]=max(a[i],bb[i])
  aa[i+1]=max(a[i+1],bb[i])
print(sum(aa))

n=int(input())
bb=list(map(int,input().split()))
aa=[0]*n
aa[0]=bb[0]
for i in range(n-1):
  aa[i]=min(aa[i],bb[i])
  aa[i+1]=max(aa[i+1],bb[i])
print(sum(aa))


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):
input_data = input().split("\n")
N = int(input_data[0])
ls = [int(b) for b in input_data[1]]
if len(ls) == 1:
  print(ls[0]*2)

first = ls[0]
als = [ls[0]]

for n in range(1, N-1):
  als.append(min(ls[n-1], ls[n]))
als.append(ls[-1])
print(sum(als))

input_data = input().split("\n")
N = int(input_data[0])
ls = [int(b) for b in input_data[1].split()]
if len(ls) == 1:
  print(ls[0]*2)
else:
  first = ls[0]
  als = [ls[0]]

  for n in range(1, N-1):
    als.append(min(ls[n-1], ls[n]))
  als.append(ls[-1])
  print(sum(als))

print(input().split())

N = int(input())
ls = [int(i) for i in input().split()]
if len(ls) == 1:
  print(ls[0]*2)
else:
  als = [ls[0]]
  for n in range(1, N-1):
    als.append(min(ls[n-1], ls[n]))
  als.append(ls[-1])
  print(sum(als))

Verdicts: Runtime Error

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

a = [b.pop()]
for b_i in b[::-1]:
  a.append(min(a[-1],b_i))
  
print(sum(a))

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

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

result = B[0]

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

print(result)

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

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

ans = 0

for i in range(n):
  if n % 2 == 0:
    ans += a[i-1]
  
print(ans)

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)

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

print(s)


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

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())
x=list(map(int,input().split()))
ans=2*x[0]+x[n-2]
if n>3:
    for i in range(1,n-2):
        if x[i-1]<x[i] and x[i+1]<x[i]:
            x[i]=max(x[i-1],x[i+1])
        ans+=x[i]
elif n==3:
    ans+=x[0]
else:
    ans-=x[n-2]
print(ans)


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

N = int(input())
B = list(map(int,input().split()))
ans = B[0]+B[N-2]
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())
B = list(map(int, input().split()))
A = []

for i, b in enumerate(B):
  print(A)
  if i == 0 and i == len(B) - 1: 
    A.append(B[i])
    A.append(B[i])
    break

  if i == 0:
    if B[i] <= B[i + 1]:
      A.append(B[i])
      A.append(B[i])
    else:
      A.append(B[i + 1])
      A.append(B[i + 1])
  elif i == len(B) - 1 and len(A) != N:
    A.append(B[i])
  else:
    if B[i] <= B[i + 1]:
      A.append(B[i])
    else:
      A.append(B[i + 1])
print(sum(A))

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

n = int(input())
b = list(map(int,input().split()))
ans = [b[0],b[-1]]
b = [float('inf')] + b + [float('inf')]
for i in range(1,n-1):
    ans.append(min(b[i],b[i+1]))
print(sum(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 = 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):
from functools import reduce
n=int(input())
b=list(map(int, input().split()))
b.extend([b[n-2],b[n-2]])

a=[]
j=0
for i in range(n):
    if i < 2:
        a.append(b[j])
        continue

    a.append(max(b[j], b[j+1]))
    print(a)
    if b[j+1] <= a[i]:
        a[i-1]=min(b[j], b[j+1])
        a[i]=min(b[j], b[j+1])
    j+=1

print(reduce(lambda x,y: x+y, a))


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

b.insert(0, float("inf"))
b.insert(len(b), float("inf"))

ans = 0
for i in range(len(b)-1, 0, -1):
    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())
B = list(map(int, input().split()))
A = [B[0]]
for i in range(1,len(B)-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(len(B)-1):
  A.append(min(B[i],B[i+1]))
A.append(B[len(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 = [int(n) for n in input().split()]
B.insert(0, 10**7)
B.append(10**7)
C = []
C.append(B[1])
for i in range(2, N-1):
    C.append(min(B[i-1], B[i]))
C.append(B[N-1])
print(sum(C))

N = int(input())
B = [int(n) for n in input().split()][::-1]
print(sum([B[0],B[N-2]]+[min(B[i-1],B[i]) for i in range(1,N-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):
n = int(input())
bn = [int(num) for num in input().split()]

an = [0]*n
an[0] = bn[0]
an[n-1] = bn[n-2]
for i in range(1,n-1):
    s = min(bn[i],bn[i-1])
    an.append(s)
    
print(sum(an))
print(an)

n = int(input())
bn = [int(num) for num in input().split()]
 
an = [0]*n
an[0] = bn[0]
an[n-1] = bn[n-2]
for i in range(1,n-1):
    s = min(bn[i],bn[i-1])
    an.append(s)
    
print(sum(an))

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.insert(0,1000000)
B.append(1000000)
for i in range(1,N+1):
  a=min(B[i],B[i-1])
  A.append(a)
print(A)  
print(sum(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.append(a)
  
print(sum(A))

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

a = [0 for _ in range(n)]

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

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

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

a = [0 for _ in range(n)]

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

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())
B=[int(b) for b in input().split()]
A=[int(a) for a in range(N)]



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

print(sum(A))
print(A)

N=int(input())
B=[int(b) for b in input().split()]
A=[int(a) for a in range(N)]



for i in range(N-2):
    if B[i]<=B[i+1]:
        A[i+1]=B[i]
    if B[i]>B[i+1]:
        A[i+1]=B[i+1]
A[0]=B[0]
A[N-1]=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())
list_b = list(map(int, input().split()))
list_a = [0]*n

list_a[0] = list_b[0]
list_a[1] = list_b[0]
for i in range(1, n-1):
  if list_b[i] < list_a[i]:
    list_a[i] = list_b[i]
    list_a[i+1] = list_b[i]
  else:
    list_a[i+1] = list_b[i]

print(list_a)
print(sum(list_a))

n = int(input())
list_b = list(map(int, input().split()))
list_a = [0]*n

list_a[0] = list_b[0]
list_a[1] = list_b[0]
for i in range(1, n-1):
  if list_b[i] < list_a[i]:
    list_a[i] = list_b[i]
    list_a[i+1] = list_b[i]
  else:
    list_a[i+1] = list_b[i]

print(sum(list_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):

a= int(input())
l = list(map(int,input().split()))
l = l[::-1]
s = 0 
for n,(x,y) in enumerate(zip(l,l[1:])):
    s+= min(x,y)
print(s+l[0])

a= int(input())
l = list(map(int,input().split()))
l = l[::-1]
t = l[0]
s = t
for n , x in enumerate(l[1:-1]):
    if x < t:  t = x
    s+=t
    # print(t)
print(s+l[-1])

a= int(input())
l = list(map(int,input().split()))
l = l[::-1]
s = l[-1]
for n,(x,y) in enumerate(zip(l,l[1:])):
    s+= min(x,y)
print(s+l[0])

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

L = B[:]
for i in range(N - 1):
    if (i >= N - 2):
        break
    elif (i == 0 and B[0] > B[1]):
        p = L.pop(0)
        L.append(p)
    elif (B[i] > B[i + 1]):
        L.pop(i)

print(L)
if (len(L) == 1):
    print(sum(B) * 2)
else:
    print(sum(L) + L[-2])


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

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

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):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

N = int(sys.stdin.readline())

a = []
b = list(map(int, sys.stdin.readline().rstrip().split()))

# print(b)

for i in range(N):
  print(i)
  
  if i == 0:
    a.append(b[i])
  elif i == N - 1:
    a.append(b[i-1])
  else:
    a.append(min(b[i-1], b[i]))


print(sum(a))

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

N = int(sys.stdin.readline())

a = []
b = list(map(int, sys.stdin.readline().rstrip().split()))

# print(b)

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

for a in B[:N-2]:
    if a < B[x]:
        result += a * count
        if x < N - 2:
            x += 1
    else:
        count += 1
        if x < N - 2:
            x += 1
        continue
print(result + B[N-2])

N = int(input())
B = list(map(int, input().split()))
A = [0]*N
for a in range(1,N-1):
    A[a] = min(B[a-1], B[a])



print(sum(A) + B[0] + B[N-2])

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

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

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):
N=int(input())
B=[10**6]
B.extend([int(b) for b in input().split()])
B.append(10**6)
print(N, B)

A=[None]*N
for i in range(N):
  A[i] = min(B[i], B[i+1])
  
print(sum(A))

N=int(input())
B=[10**6]
B.extend([int(b) for b in input().split()])
B.append(10**6)


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

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

print(res)

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

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

a = [0]*n
b.append(1000000)

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

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

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

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

if n == 2:
    print(b[0]*2)
elif n==3:
    print(b[1]+min(b[0],b[1])*2)
else:
    co = [min(x , y) for (x, y) in zip(b[0:-1], b[1:])]
    print(sum(co)+b[-1]+b[0])


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

tmp_b = 0
for b in B:
    max_a = min(tmp_b,b)
    ans += max_a 
    tmp_b = b

max_a = B[-1]
ans += max_a

print(ans)


N = int(input())

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

ans = 0
tmp_b = 0

tmp_b = B[0]
for b in B:
    max_a = min(tmp_b,b)
    ans += max_a 
    tmp_b = b

max_a = B[-1]
ans += max_a

print(ans)


Verdicts: Wrong Answer

Accepted