[Python] 11651번 좌표 정렬하기2

이세령·2023년 5월 29일
0

알고리즘

목록 보기
18/43

문제

https://www.acmicpc.net/problem/11651

풀이과정

  • 어제 푼 문제랑 다르게 y좌표가 우선순위가 높게 설정해야 한다.
import sys

n = int(input())
result = []
for _ in range(n):
    result.append(sys.stdin.readline().rstrip().split())

result.sort(key=lambda x: (int(x[1]), int(x[0])))  # y를 먼저 우선으로

for i in range(n):
    print(int(result[i][0]), int(result[i][1]))

메모리: 74564KB
시간: 416 ms

profile
https://github.com/Hediar?tab=repositories

0개의 댓글