코딩테스트 with PYTHON
[python] 코딩테스트 대비 - 점수계산
탱이나라
2021. 12. 13. 23:32
문제)
답안 코드)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import sys
#sys.stdin=open("input.txt","rt")
N=int(input())
box=list(map(int,input().split()))
weight=1
score=0
for i in box:
if i==1:#맞췄을때
score+=weight*i
weight+=1
else:#맞추지 못했을때
weight=1
print(score)
|
cs |