지나가던 개발자
[Python] 백준 4821번(페이지 세기) 문제 풀이 본문
while True:
pages = [False for i in range(int(input()))]
if len(pages) == 0:
break
toPrint = input().split(",")
for i in toPrint:
to_print = list(map(int, i.split("-")))
if to_print[0] > len(pages):
continue
if len(to_print) == 1:
pages[to_print[0]-1] = True
continue
if to_print[0] > to_print[1]:
continue
if to_print[1] > len(pages):
to_print[1] = len(pages)
for j in range(to_print[0], to_print[1]+1):
pages[j-1] = True
print(pages.count(True))
백준에 다크 모드를 적용해 보았다. 눈이 편안하다.
'PS > Python' 카테고리의 다른 글
[Python] 백준 11721번(열 개씩 끊어 출력하기) 문제 풀이 (0) | 2022.11.05 |
---|---|
[Python] 백준 10826번(피보나치 수 4) 문제 풀이 (0) | 2022.11.04 |
[Python] 백준 8892번(팰린드롬) 문제 풀이 (0) | 2022.11.02 |
[Python] 백준 2941번(크로아티아 알파벳) 문제 풀이 (0) | 2022.11.01 |
[Python] 백준 5800번(성적 통계) 문제 풀이 (0) | 2022.10.31 |
Comments