Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a, b = [int(x) for x in input().split(" ")]
- ludia = [([]) for x in range(0, a)]
- for i in range(0, a):
- temp = input().split(" ")
- ludia[i].append(temp[0])
- ludia[i].append(temp[1])
- ludia[i][1] = int(ludia[i][1])
- dll = 0
- for i in range(0, a):
- if i >= (a-dll):
- break
- for j in range(1, a):
- if j is not i:
- if j >= (a-dll):
- break
- elif ludia[i][0] == ludia[j][0]:
- ludia[i][1] += int(ludia[j][1])
- del ludia[j]
- dll += 1
- sup = 0
- ludia.sort(key = lambda x: -x[1])
- leng = len(ludia)
- for i in range(0, b):
- if b >= leng:
- break
- sup += ludia[i][1]
- print(sup)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement