Skip to content

Instantly share code, notes, and snippets.

@IKKO-Ohta
Created July 4, 2017 16:04
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 IKKO-Ohta/e60025ba41079037fec27d53ed06bb58 to your computer and use it in GitHub Desktop.
Save IKKO-Ohta/e60025ba41079037fec27d53ed06bb58 to your computer and use it in GitHub Desktop.
nums=[int(x) for x in input().split()]
N,H=nums[0],nums[1]
nums=[int(x) for x in input().split()]
A,B,C,D,E=nums[0],nums[1],nums[2],nums[3],nums[4]
costs=[]
for x in range(N):
minY = max(0,(((N-X)*E - H - B*x) // (D+E)) + 1)
costs.append(B*x + D*minY)
print(min(costs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment