https://www.acmicpc.net/problem/16466
16466번: 콘서트
HCPC (Hanyang Completely Perfect Celebrity)는 한양대학교 최고의 가수에게 주어지는 칭호이다. 한양대학교는 매년 최고의 HCPC를 선발한다. HCPC가 되기란 여간 어려운 게 아니다. 매일 아침 날달걀을 까먹
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
|
import sys
n=int(sys.stdin.readline())
nums=sorted(list(map(int, sys.stdin.readline().split())))
is_full=1
for i in range(len(nums)):
if (i+1)!=nums[i]:
print(i+1)
is_full=0
break
if is_full == 1:
print(n+1)
|
cs |
이 문제는 정렬 문제고, sort()함수써서 숫자 정렬시키고 index+1 번과 그 위치의 숫자가 일치하지 않으면 index+1 번을 출력하고
혹시 전부 일치하게 되면 n+1 을 출력하면됩니다!
This problem is about Sorting,
First you can sort numbers with sort() function
Second If Index+1 is not equal to (index+1)'s number print(index+1)
else print n+1
반응형
'python-algorithm' 카테고리의 다른 글
백준 1251 단어 나누기 (0) | 2022.10.17 |
---|---|
백준 17335 APC는 왜 서브태스크 대회가 되었을까? (0) | 2022.10.14 |
백준 2204 도비의 난독증 테스트 (0) | 2022.10.12 |
백준 10989 수 정렬하기 3 (0) | 2022.10.11 |
백준 25629 홀짝 수열 (0) | 2022.10.10 |
댓글