結果

問題 No.2227 King Kraken's Attack
ユーザー titiatitia
提出日時 2023-03-01 06:52:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 74,148 KB
最終ジャッジ日時 2024-04-10 09:50:28
合計ジャッジ時間 5,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,000 KB
testcase_01 AC 35 ms
53,052 KB
testcase_02 AC 35 ms
52,836 KB
testcase_03 AC 56 ms
65,644 KB
testcase_04 AC 35 ms
53,152 KB
testcase_05 AC 35 ms
52,808 KB
testcase_06 AC 49 ms
64,472 KB
testcase_07 AC 44 ms
61,604 KB
testcase_08 AC 43 ms
62,384 KB
testcase_09 AC 58 ms
69,060 KB
testcase_10 AC 39 ms
55,104 KB
testcase_11 AC 49 ms
64,220 KB
testcase_12 AC 44 ms
61,084 KB
testcase_13 AC 47 ms
63,360 KB
testcase_14 WA -
testcase_15 AC 226 ms
60,664 KB
testcase_16 AC 194 ms
61,264 KB
testcase_17 AC 427 ms
68,036 KB
testcase_18 AC 54 ms
60,620 KB
testcase_19 AC 53 ms
64,072 KB
testcase_20 AC 54 ms
65,108 KB
testcase_21 AC 105 ms
69,488 KB
testcase_22 AC 131 ms
61,528 KB
testcase_23 AC 51 ms
63,232 KB
testcase_24 AC 117 ms
65,036 KB
testcase_25 AC 159 ms
60,836 KB
testcase_26 WA -
testcase_27 AC 50 ms
61,032 KB
testcase_28 AC 77 ms
74,148 KB
testcase_29 AC 64 ms
69,216 KB
testcase_30 AC 174 ms
74,136 KB
testcase_31 AC 76 ms
69,884 KB
testcase_32 AC 64 ms
68,976 KB
testcase_33 AC 66 ms
70,256 KB
testcase_34 AC 63 ms
69,732 KB
testcase_35 AC 77 ms
74,148 KB
testcase_36 AC 60 ms
67,752 KB
testcase_37 AC 37 ms
53,584 KB
testcase_38 AC 37 ms
53,292 KB
testcase_39 AC 37 ms
54,336 KB
testcase_40 AC 37 ms
53,928 KB
testcase_41 AC 36 ms
52,128 KB
testcase_42 AC 37 ms
53,236 KB
testcase_43 AC 36 ms
52,876 KB
testcase_44 AC 36 ms
53,012 KB
testcase_45 AC 40 ms
59,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W,LA,LB,KA,KB=map(int,input().split())

ANS=10**9

for yoko in range((H+LA-1)//LA+1):
    teki=H*W
    
    yoko_damage=W*min(H,yoko*LA)
    no_damage=teki-yoko_damage

    if no_damage>=KA*yoko:
        no_damage-=KA*yoko
    else:
        yoko_damage-=KA*yoko-no_damage
        no_damage=0

    #print(yoko,yoko_damage,no_damage)

    if yoko_damage<=0 and no_damage<=0:
        ANS=min(ANS,yoko)
        continue

    NG=0
    OK=10**6+1

    while OK>NG+1:
        mid=(OK+NG)//2

        rest=max(0,yoko_damage-min(W,mid*LB)*min(H,yoko*LA))+no_damage

        if mid*KB>=rest:
            OK=mid
        else:
            NG=mid

    #print(yoko,OK)
    ANS=min(ANS,yoko+OK)

H,W=W,H
LA,LB=LB,LA
KA,KB=KB,KA

for yoko in range((H+LA-1)//LA+1):
    teki=H*W
    
    yoko_damage=W*min(H,yoko*LA)
    no_damage=teki-yoko_damage

    if no_damage>=KA*yoko:
        no_damage-=KA*yoko
    else:
        yoko_damage-=KA*yoko-no_damage
        no_damage=0

    #print(yoko,yoko_damage,no_damage)

    if yoko_damage<=0 and no_damage<=0:
        ANS=min(ANS,yoko)
        continue

    NG=0
    OK=10**6+1

    while OK>NG+1:
        mid=(OK+NG)//2

        rest=max(0,yoko_damage-min(W,mid*LB)*min(H,yoko*LA))+no_damage

        if mid*KB>=rest:
            OK=mid
        else:
            NG=mid

    #print(yoko,OK)
    ANS=min(ANS,yoko+OK)


print(ANS)
    

0