본 내용은 파이썬 알고리즘 문제풀이 (코딩테스트 대비) 강의를 토대로 작성하였습니다.
# 점수계산
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)
'Algorithm > 파이썬 알고리즘 문제풀이' 카테고리의 다른 글
[python/inflearn/section3] 숫자만 추출 (0) | 2022.09.22 |
---|---|
[python/inflearn/section3] 회문 문자열 검사 (0) | 2022.09.22 |
[python/inflearn/section2] 주사위게임 (0) | 2022.09.18 |
[python/inflearn/section2] 뒤집은 소수 (0) | 2022.09.18 |
[python/inflearn/section2] 소수(에라토스테네스 체) (0) | 2022.09.18 |