Skip to content

Instantly share code, notes, and snippets.

@modos
Created April 25, 2023 05:16
Show Gist options
  • Save modos/d7d7a30e3f53d962fd67f7a5ffe12650 to your computer and use it in GitHub Desktop.
Save modos/d7d7a30e3f53d962fd67f7a5ffe12650 to your computer and use it in GitHub Desktop.
جعبه شکلات
s = input()
s = s.split()
for i in range(0, len(s)):
s[i] = int(s[i])
k, v, n = s[0], s[1], s[2]
a = input()
a = a.split()
for i in range(0, len(a)):
a[i] = int(a[i])
c = input()
c = c.split()
for i in range(0, len(c)):
c[i] = int(c[i])
boxes = []
count = 0
for i in range(n):
if c[i] <= v and a[i] >= k + 1 and a[i] % (k + 1) == 1:
boxes.append(c[i])
boxes.sort()
for i in range(len(boxes)):
if v >= boxes[i]:
v = v - boxes[i]
count = count + 1
else:
break
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment