Untitled
unknown
plain_text
6 days ago
695 B
3
Indexable
Never
m, n = map(int, input().split()) cook = list(map(int, input().split())) clean = list(map(int, input().split())) diff = [(i, cook[i] - clean[i]) for i in range(len(cook))] diff.sort(key=lambda k: -k[1]) rcook = 0 rclean = 0 pcook = set() pclean = set() for i in range(m): rcook += cook[diff[i][0]] pcook.add(diff[i][0]) for i in range(m+1, n + m + 1): rclean += clean[diff[i][0]] pclean.add(diff[i][0]) for i in range(len(cook)): unsure = diff[m][0] if i in pcook: print(rcook - cook[i] + rclean + cook[unsure], end=' ') elif i in pclean: print(rcook - clean[i] + rclean + clean[unsure], end=' ') else: print(rcook + rclean, end=' ')
Leave a Comment