Skip to content

Instantly share code, notes, and snippets.

@abidkhan484
Last active September 17, 2018 17:32
Show Gist options
  • Select an option

  • Save abidkhan484/ce892575c910df24fe9b1a4ad82df2e8 to your computer and use it in GitHub Desktop.

Select an option

Save abidkhan484/ce892575c910df24fe9b1a4ad82df2e8 to your computer and use it in GitHub Desktop.
# not yet solved
# a test case: 15 5 2 3
n, a, b, c = map(int, input().split())
a, b, c = sorted([a,b,c])
p, q, r = (n//a)+1, (n//b)+1, (n//c)+1
maximum = -1
for i in range(r):
for j in range(q):
for k in range(p):
total = (i*c) + (j*b) + (k*a)
if (total==n):
print(i, c, j,b,k,a)
if total == n and (i+j+k) > maximum:
maximum = i+j+k
print(maximum)
@abidkhan484
Copy link
Author

abidkhan484 commented Sep 17, 2018

TLE with the test case below. and it's natural
4000 1 2 3

That means the fuc*ing approach should be changed.... 🔢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment