가중치 기준 내림차순 정렬하고 마지막날부터 거꾸로 먹는다.
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
w_ps = [list(map(int, input().split())) for _ in range(N)]
w_ps.sort(key = lambda x: x[1],reverse=True)
answer = 0
for w, p in w_ps:
answer += (w + p*(T-1))
T -= 1
print(answer)
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 18860 좌표압축 (1) | 2021.08.31 |
---|---|
[백준][Python] 11724 연결요소의 개수 (0) | 2021.08.31 |
[백준][Python] 18352 특정거리의 도시찾기 (0) | 2021.08.31 |
[백준][Python] 14442 벽 뿌수고 이동하기2 (1) | 2021.08.30 |
[백준][Python] 14938 서강그라운드 (0) | 2021.08.30 |