728x90
문제
N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성하시오.
My code
import sys
n = int(input())
num = []
for _ in range(n):
num.append(int(sys.stdin.readline()))
num.sort()
for i in num:
print(i)
TIL
- Python 내장함수인 sort()는:
- Stable Sort이다. 즉, 중복된 값의 경우 입력 순서와 동일하게 정렬한다.
- O(NlogN)이다.
728x90
'Computer Science > 백준' 카테고리의 다른 글
[백준 / Python] 11052 : 카드 구매하기 (1) | 2023.10.04 |
---|---|
[백준 / Python] 1463 : 1로 만들기 (0) | 2023.10.04 |
[백준 / Python] 6588 : 골드바흐의 추측 (0) | 2023.09.23 |
[백준 / Python] 1676: 팩토리얼 0의 개수 (0) | 2023.09.23 |
[백준 / Python] 1316: 그룹 단어 체커 (0) | 2023.09.13 |