n=int(input())
arr=[]
for i in range(n):
x,y=(map(int,input().split()))
arr.append([y,x])
arr.sort()
for i in range(n):
print(arr[i][1], arr[i][0])
시간초과
import sys
n = int(sys.stdin.readline())
arr=[]
for i in range(n):
arr.append(list(map(int,input().split())))
for i in range(n-1):
for j in range(n-i-1):
if arr[j][1]>arr[j+1][1]:
temp=arr[j]
arr[j]=arr[j+1]
arr[j+1]=temp
for i in range(n):
print(arr[i][0], arr[i][1])
import sys
n = int(sys.stdin.readline())
arr=[0]*n
for i in range(n):
arr[i]=(list(map(int,input().split())))
for i in range(n-1):
for j in range(n-i-1):
if arr[j][1]>arr[j+1][1]:
temp=arr[j]
arr[j]=arr[j+1]
arr[j+1]=temp
for i in range(n):
print(arr[i][0], arr[i][1])
여전히 시간 에러~~~
=> 시간 초과 too much .. 개선하자