LoginSignup
0
0

More than 1 year has passed since last update.

ABC140 C - Maximal Value を解いた

Posted at

abc140_1.png
abc140_2.png

問題文の通りに書いてみた

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

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0