Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save easyforgood/dfb01317f70a78a1405f44a71d9903fa to your computer and use it in GitHub Desktop.
Save easyforgood/dfb01317f70a78a1405f44a71d9903fa to your computer and use it in GitHub Desktop.
import math
def dataInput():
(N,P,W,H)=(int(x) for x in raw_input().split())
initData=[int(x) for x in raw_input().split()]
return N,P,W,H,initData
def getResult():
N,P,W,H,initData=dataInput()
max=1
def getMax(max):
while True:
sum=0
for i in range(N):
if int(W/max)==0:
return max-1
if int(H/max) ==0:
return max-1
else:
sum=sum+int(math.ceil(initData[i]/(int(W/max))))*max
temp=int(math.ceil(sum/int(H/max)))
if temp <= P*H:
max=max+1
continue
if temp> P*H:
return max-1
return getMax(1)
while True:
try:
n = int(raw_input())
result=[getResult() for x in range(n)]
for i in result:
print i
except EOFError:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment