Skip to content

Instantly share code, notes, and snippets.

@Truthstone
Created May 23, 2020 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Truthstone/1cc17799b7737b669937ba4c21eb3b1c to your computer and use it in GitHub Desktop.
Save Truthstone/1cc17799b7737b669937ba4c21eb3b1c to your computer and use it in GitHub Desktop.
Google Hash Code Solution of qualification round of year 2020
maxp, nop, = list(map(int,input().split()))
pizza = list(map(int,input().split()))
count = 0
while sum(pizza) > maxp:
diff = sum(pizza) - maxp
data = pizza[min(range(len(pizza)), key=lambda j:abs(pizza[j]-diff))]
pizza[pizza.index(data)] = 0
count = count + 1
print(str(len(pizza)-count))
for i in range(len(pizza)):
if pizza[i] != 0:
print(str(i), end="")
print(" ", end="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment