PS/BOJ
[백준] 나이순 정렬
RUBY_루비
2020. 10. 5. 23:59
출처:: www.acmicpc.net/problem/10814
분류:: 정렬
1. 문제 이해 및 해결과정
2. 풀이방법
1. [ python ]
#나이순 정렬
#https://www.acmicpc.net/problem/10814
import sys
sys.stdin = open("input.txt","r")
n=int(input())
arr=[]
for i in range(n):
x,y=input().split()
arr.append((int(x),y,int(i)))
arr.sort(key=lambda x:(x[0],x[2],x[1]))
for x,y,z in arr:
print(x,y)
3. 오답원인
- 데이터 입력시 정수를 기준으로 정렬해야 하기 때문에 int로 입력해야한다
반례
2
2 a
10 b
4. 알게된 점