#45789: 求援助(75%)


linswater (linswater)

學校 : 國立武陵高級中學
編號 : 297974
來源 : [36.224.93.12]
最後登入時間 :
2025-10-05 16:14:00

n = int(input(""))
w1,w2,h1,h2 = list(map(int,input("").split()))
volume = [int(n) for n in input("").split()]
a = [w1**2,w2**2]
h = [h1,h2]
delta = []
for vol in volume:
    height = vol/a[0]
    if height < h[0]:
        delta.append(height)
        h[0] -= height
    elif height >= h[0]:
        if len(a) == 2:
            extra = (a[0]*(height-h[0]))/a[1]
            delta.append(h[0]+ extra)
            a.pop(0)
            h.pop(0)
            h[0] -= extra
        else:
            delta.append(h[0])
            break
print(int(max(delta)))
#45790: Re: 求援助(75%)


leeguanhan0909@gmail.com (李冠翰)

學校 : 高雄市苓雅區復華高級中學國中部
編號 : 276558
來源 : [36.238.189.188]
最後登入時間 :
2025-06-11 22:19:49

n = int(input(""))
w1,w2,h1,h2 = list(map(int,input("").split()))
volume = [int(n) for n in input("").split()]
a = [w1**2,w2**2]
h = [h1,h2]
delta = []
for vol in volume:
    height = vol/a[0]
    if height < h[0]:
        delta.append(height)
        h[0] -= height
    elif height >= h[0]:
        if len(a) == 2:
            extra = (a[0]*(height-h[0]))/a[1]
            delta.append(h[0]+ extra)
            a.pop(0)
            h.pop(0)
            h[0] -= extra
        else:
            delta.append(h[0])
            break
print(int(max(delta)))

在計算extra時要考慮是否超過h[1]

#45855: Re: 求援助(75%)


linswater (linswater)

學校 : 國立武陵高級中學
編號 : 297974
來源 : [36.224.93.12]
最後登入時間 :
2025-10-05 16:14:00

n = int(input(""))
w1,w2,h1,h2 = list(map(int,input("").split()))
volume = [int(n) for n in input("").split()]
a = [w1**2,w2**2]
h = [h1,h2]
delta = []
for vol in volume:
    height = vol/a[0]
    if height < h[0]:
        delta.append(height)
        h[0] -= height
    elif height >= h[0]:
        if len(a) == 2:
            extra = (a[0]*(height-h[0]))/a[1]
            delta.append(h[0]+ extra)
            a.pop(0)
            h.pop(0)
            h[0] -= extra
        else:
            delta.append(h[0])
            break
print(int(max(delta)))

在計算extra時要考慮是否超過h[1]

謝謝回應