[파이썬]백준 2851 슈퍼마리오

Byeonghyeon Kim·2021년 2월 25일
0

알고리즘문제

목록 보기
11/93
post-thumbnail

링크

백준 2851 슈퍼마리오


어차피 점수는 순서대로 올라가니 100을 넘어갈 때 점수와 직전 점수를 비교해주었다.


정답 코드

score = 0
mushrooms = []
for _ in range(10):
    mushrooms.append(int(input()))

for i in range(10):
    ex_score = score
    score += mushrooms[i]
    if score >= 100:
        under = 100 - ex_score
        over = score - 100
        if over <= under:
            print(score)
            break
        else:
            print(ex_score)
            break
else:
    print(score)

알게된 것👨‍💻

profile
자기 주도 개발전 (개발, 발전)

0개의 댓글