https://www.acmicpc.net/problem/11651
✨ 문제
2차원 평면 위의 점 N개가 주어진다. 좌표를 y좌표가 증가하는 순으로, y좌표가 같으면 x좌표가 증가하는 순서로 정렬한 다음 출력하는 프로그램을 작성하시오.
내 코드
import sys
import random
input = sys.stdin.readline
def main() :
N = int(input())
array = []
for i in range(N) :
x, y = list(map(int, input().rstrip().split()))
array.append((x,y))
array.sort(key=lambda p:(p[1],p[0]))
for p in array :
print(p[0],p[1])
if __name__ =="__main__" :
main()
느낀점
1. sort 메소드는 참 좋다
풀이시간

'알고리즘 > 백준' 카테고리의 다른 글
| 백준 2231번 : 분해합(B2) (0) | 2025.01.23 |
|---|---|
| 백준 2798번 : 블랙잭(B2) (0) | 2025.01.22 |
| 백준 11650번 : 좌표정렬하기(S5) (0) | 2025.01.21 |
| 백준 1427번 : 소트인사이드(S5) (0) | 2025.01.21 |
| 백준 25305번 : 커트라인(B2) (0) | 2025.01.21 |