#45789: 求援助(75%)


linswater (linswater)

學校 : 國立武陵高級中學
編號 : 297974
來源 : [36.224.114.40]
最後登入時間 :
2025-04-12 21:26:24
o711. 1. 裝飲料 -- 2024年10月APCS | From: [36.224.114.40] | 發表日期 : 2025-04-12 22:03

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.153.220]
最後登入時間 :
2025-04-05 17:05:47
o711. 1. 裝飲料 -- 2024年10月APCS | From: [36.238.164.70] | 發表日期 : 2025-04-13 01:17

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]

 
ZeroJudge Forum