728x90
9443번: Arrangement of Contest
Little Dmitry and little Petr want to arrange a contest. Their little friends submitted several task proposals and now Dmitry and Petr want to select some of them for the contest. As they are just little boys, they cannot estimate quality of tasks, but the
www.acmicpc.net
문제 풀이
이 문제는 set 자료구조를 활용해서 주어지는 입력값의 첫 번째 문자들의 종류를 구해준다. 그 후, A ~ Z 까지 순차적으로 set안에 포함되어있는지 검사하고, 없다면 검사 종료 후 지금까지 검사한 수를 출력한다.
정답 코드
ans = set()
for i in range(int(input())) :
s = input()
ans.add(s[0])
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
idx = 0
while idx < 26 :
if alpha[idx % 26] not in ans : break
idx += 1
print(idx)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9493 - 길면 기차, 기차는 빨라, 빠른 것은 비행기 [python] (0) | 2023.03.25 |
---|---|
[BOJ/백준] 9469 - 폰 노이만 [python] (0) | 2023.03.25 |
[BOJ/백준] 9366 - 삼각형 분류 [python] (0) | 2023.03.24 |
[BOJ/백준] 9325 - 얼마? [python] (0) | 2023.03.24 |
[BOJ/백준] 9317 - Monitor DPI [python] (0) | 2023.03.24 |