https://www.acmicpc.net/problem/11651
from sys import stdin
N = int(stdin.readline())
coords = []
for _ in range(N):
x, y = map(int, stdin.readline().split())
coords.append((x, y))
coords.sort(key = lambda x: (x[1], x[0]))
for x, y in coords:
print(x, y)
입력받은 좌표들을 y 좌표 -> x 좌표 순으로 기준을 잡고 정렬
https://www.acmicpc.net/problem/11399
from sys import stdin
N = int(stdin.readline())
P = list(map(int, stdin.readline().split()))
P.sort()
ans = 0
for i in range(N):
ans += P[i] * (N-i)
print(ans)
N = 5
이고 [P1, P2, P3, P4, P5]
의 순서일 때
시간의 합은 P1 * 5 + P2 * 4 + P3 * 3 + P4 * 2 + P5 * 1
이 된다.
여기서 최소 시간합이 되려면 상대적으로 큰 숫자를 곱하는 앞 순서의 P 값들이 작아야 한다.
따라서 정렬 후 P * N-i
를 모두 더해주면 된다.