Created
May 23, 2020 10:51
-
-
Save Truthstone/1cc17799b7737b669937ba4c21eb3b1c to your computer and use it in GitHub Desktop.
Google Hash Code Solution of qualification round of year 2020
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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