본문 바로가기

Algorithm/파이썬 알고리즘 문제풀이

[python/inflearn/section2] 점수계산

본 내용은 파이썬 알고리즘 문제풀이 (코딩테스트 대비) 강의를 토대로 작성하였습니다.

이미지 클릭시, 강의로 이동됩니닷 :)

# 점수계산
import sys
#sys.stdin=open("input.txt", "r")

n = int(input())
num_list = list(map(int, input().split()))
total = 0
cnt = 0
for i in range(n):
    if num_list[i] == 1:
        cnt +=1
        total+=cnt
    else :
        cnt = 0

print(total)