Advertisement
Farz0l1x

Untitled

May 1st, 2024
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. file = open('6.txt')
  2. K, M, N = map(int, file.readline().split())
  3. a = [int(x) for x in file]
  4. a.sort(reverse= True)
  5. pl = [M] * K
  6. count = 0
  7. for i in range(N):
  8.     req = a[i]
  9.     for j in range(K):
  10.         if pl[j] >= req:
  11.             pl[j] -= req
  12.             count += 1
  13.             break
  14. print(count, sum(pl))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement