Skip to content

Commit d715bee

Browse files
committed
[BOJ] #2847. 게임을 만든 동준이 / 실버4 / 53분 / 힌트 -> 성공
1 parent 18eb819 commit d715bee

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 입력 예시: N과 각 레벨 점수 리스트
2+
N = int(input())
3+
scores = [int(input()) for _ in range(N)]
4+
5+
# 감소 횟수 변수
6+
answer = 0
7+
8+
# 가장 높은 레벨부터 시작해서 점수를 조정
9+
for i in range(N - 2, -1, -1): # 뒤에서 두 번째 레벨부터 첫 번째 레벨까지
10+
if scores[i] >= scores[i + 1]: # 다음 레벨 점수보다 크거나 같다면
11+
answer += scores[i] - (scores[i + 1] - 1) # 감소해야 하는 횟수 증가
12+
scores[i] = scores[i + 1] - 1 # 다음 레벨보다 1 작게 설정
13+
14+
# 결과 출력
15+
print(answer)

0 commit comments

Comments
 (0)