ABC135 C - City Savers에서 배운
                                            
                                                
                                                
                                                
                                                
                                                
                                                 8012 단어  AtCoder파이썬AtCoderBeginnerContest
                    




음, 알겠어
DP 같은-. . 라고 쓰면
전혀 다르다 (웃음)
CitySavers.py
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
score = 0
marg = 0
for i in range(N):
    num = A[i]-marg
    if num > 0:
        score += marg
        A[i] -= marg
        if B[i] >= A[i]:
            score += A[i]
            marg = B[i]-A[i]
        else:
            score += B[i]
            marg = 0 # <= ここを忘れて WA (泣)
    else:
        score += A[i]
        marg = B[i]
if A[-1]-marg >= 0:
    score += marg
else:
    score += A[-1]
print(score)#123ms
for 문으로 어디서나 빠져도
처리하고 있는 인수는 모두 의도했다
형식이되도록 의식이 필요하다면
다시 인식했다.
다시 도전.
설명을 약간 최적화 할 수 있습니다.
그리고 WA를 먹지 않고 한 번 OK!!
조금 시간을 들여 신중하게 했으니까 당연한가. .
다음 번은 바삭하게 할 수 있게 되기를 기도한다.
abc135c.py
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sup = 0
cnt = 0
for i in range(N):
    a,b = A[i],B[i]
    if a <= b:
        cnt += a
        if A[i+1] >= b-a:
            A[i+1] -= b-a
            cnt += b-a
        else:
            cnt += A[i+1]
            A[i+1] = 0
    else:
        cnt += b
print(cnt)#119ms
                Reference
이 문제에 관하여(ABC135 C - City Savers에서 배운), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/AKpirion/items/15eff532816bf305863f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)