-
[백준] 10814 나이 순으로 정렬하기백준 Online Judge 2021. 8. 27. 16:20
문제 해설
- 나이 순으로 정렬 하기
- 첫 번째 입력 값은 몇 명의 사람이 입력되는지 보여 준다.
- 나이가 같을 때는 입력이 먼저 된 사람부터 보여 준다.
- 튜플을 사용하면 쉽게 풀 수 있다.
n = int(input()) array = [] # array는 리스트 형태 for _ in range(n): input_data = input().split(' ') # 리스트 array에 튜플 형태로 데이터 삽입 array.append((input_data[0], input_data[1])) array = sorted(array, key=lambda x:x[0]) for i in array: print(i[0], i[1])
GitHub - DAWUNHAN/Algorithms-and-DataStructure: Algorithms and DataStructure with Python
Algorithms and DataStructure with Python. Contribute to DAWUNHAN/Algorithms-and-DataStructure development by creating an account on GitHub.
github.com
[ 패스트캠퍼스 알고리즘 / 기술면접 완전 정복 올인원 패키지 Online ] 강의 내용을 정리한 자료입니다.
'백준 Online Judge' 카테고리의 다른 글
[백준] 10989 수 정렬하기 (0) 2021.08.30 [백준] 11650 좌표 정렬하기 (0) 2021.08.30 [백준] 1427 숫자 내림차순 정렬 (0) 2021.08.27 [백준] 2750 수 정렬 (0) 2021.08.27 [백준] ⭐⭐ 4195 친구 네트워크 (0) 2021.08.26