Created
April 6, 2016 23:12
-
-
Save easyforgood/dfb01317f70a78a1405f44a71d9903fa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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