Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file = open('6.txt')
- K, M, N = map(int, file.readline().split())
- a = [int(x) for x in file]
- a.sort(reverse= True)
- pl = [M] * K
- count = 0
- for i in range(N):
- req = a[i]
- for j in range(K):
- if pl[j] >= req:
- pl[j] -= req
- count += 1
- break
- print(count, sum(pl))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement