用最笨的方法得最多的分……
num = int(input()) level = [] for i in range(num): newin = input().split() l = [int(newin[0]), int(newin[1])] level.append(l) Expanded = [] Score = 0 for i in range(num): if level[i][1] == 0: Expanded.append(i) Score += level[i][0] while len(Expanded) != len(level): maxi = 0 nextind = 0 Frontier = [] for i in range(num): if i not in Expanded: F = [i, Score + level[i][0], Score * 2] Frontier.append(F) for front in Frontier: if front[1] > maxi: maxi = front[1] nextind = front[0] if front[2] > maxi: maxi = front[2] nextind = front[0] Score = maxi Expanded.append(nextind) print(Score)
全部评论
(0) 回帖