Bad_Programist

Untitled

Jan 31st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. n, m = list(map(int, input().split()))
  2. Nums = list(map(int, input().split()))
  3. Price = list(map(int, input().split()))
  4. Clients = [0 for i in range(m)]
  5. check = [0] * n
  6. for j in range(m):
  7.     res = 0
  8.     typ, k = list(map(int, input().split()))
  9.     if Nums == check:
  10.         continue
  11.     for i in range(k):
  12.         if Nums[typ - 1] != 0:
  13.             res += Price[typ - 1]
  14.             Nums[typ - 1] -= 1
  15.         elif Nums != check:
  16.             d = Price.index(max(Price))
  17.             for s in range(n - 1, -1, -1):
  18.                 if Price[s] <= Price[d] and Nums[s] != 0:
  19.                     d = s
  20.             Nums[d] -= 1
  21.             res += Price[d]
  22.         else:
  23.             res = 0
  24.     print(res)
Advertisement
Add Comment
Please, Sign In to add comment