Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, m = list(map(int, input().split()))
- Nums = list(map(int, input().split()))
- Price = list(map(int, input().split()))
- Clients = [0 for i in range(m)]
- check = [0] * n
- for j in range(m):
- res = 0
- typ, k = list(map(int, input().split()))
- if Nums == check:
- continue
- for i in range(k):
- if Nums[typ - 1] != 0:
- res += Price[typ - 1]
- Nums[typ - 1] -= 1
- elif Nums != check:
- d = Price.index(max(Price))
- for s in range(n - 1, -1, -1):
- if Price[s] <= Price[d] and Nums[s] != 0:
- d = s
- Nums[d] -= 1
- res += Price[d]
- else:
- res = 0
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment