#37276: python 紀錄


BensonDC (python戰士)

學校 : 不指定學校
編號 : 240921
來源 : [1.175.217.87]
最後登入時間 :
2024-03-27 12:33:26
g774. 校隊 (School Team) -- TOI練習賽202111潛力組 | From: [36.238.104.63] | 發表日期 : 2023-08-29 16:39

# 根本不用動態規劃

N,M=map(int,input().split())
L=[]
for i in range(N+M):
    L.append([int(x) for x in input().split()])
L=sorted(L, key=lambda x:x[0]-x[1])[::-1]
S=0
i=0
while i<M:
    S+=L[i][1]
    i+=1
while i<M+N:
    S+=L[i][0]
    i+=1
print(S)

 
ZeroJudge Forum