結果

問題 No.2227 King Kraken's Attack
ユーザー titiatitia
提出日時 2023-03-01 06:57:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 564 ms / 2,000 ms
コード長 1,429 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 75,176 KB
最終ジャッジ日時 2024-04-10 09:50:39
合計ジャッジ時間 4,994 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,340 KB
testcase_01 AC 33 ms
53,088 KB
testcase_02 AC 32 ms
53,744 KB
testcase_03 AC 49 ms
64,116 KB
testcase_04 AC 33 ms
52,132 KB
testcase_05 AC 34 ms
53,536 KB
testcase_06 AC 34 ms
52,484 KB
testcase_07 AC 33 ms
52,744 KB
testcase_08 AC 33 ms
53,436 KB
testcase_09 AC 57 ms
68,552 KB
testcase_10 AC 35 ms
53,780 KB
testcase_11 AC 33 ms
52,832 KB
testcase_12 AC 41 ms
62,036 KB
testcase_13 AC 43 ms
63,024 KB
testcase_14 AC 33 ms
53,032 KB
testcase_15 AC 33 ms
53,256 KB
testcase_16 AC 32 ms
52,488 KB
testcase_17 AC 564 ms
69,032 KB
testcase_18 AC 51 ms
60,612 KB
testcase_19 AC 34 ms
53,468 KB
testcase_20 AC 55 ms
66,116 KB
testcase_21 AC 143 ms
67,316 KB
testcase_22 AC 155 ms
61,180 KB
testcase_23 AC 51 ms
62,760 KB
testcase_24 AC 122 ms
65,516 KB
testcase_25 AC 365 ms
75,176 KB
testcase_26 AC 388 ms
62,440 KB
testcase_27 AC 48 ms
61,736 KB
testcase_28 AC 69 ms
66,008 KB
testcase_29 AC 58 ms
65,432 KB
testcase_30 AC 210 ms
68,128 KB
testcase_31 AC 76 ms
66,164 KB
testcase_32 AC 59 ms
67,144 KB
testcase_33 AC 57 ms
65,932 KB
testcase_34 AC 54 ms
65,504 KB
testcase_35 AC 63 ms
69,012 KB
testcase_36 AC 53 ms
63,672 KB
testcase_37 AC 34 ms
53,740 KB
testcase_38 AC 35 ms
53,164 KB
testcase_39 AC 35 ms
53,420 KB
testcase_40 AC 37 ms
53,376 KB
testcase_41 AC 37 ms
53,000 KB
testcase_42 AC 36 ms
52,760 KB
testcase_43 AC 36 ms
52,416 KB
testcase_44 AC 36 ms
52,836 KB
testcase_45 AC 41 ms
59,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if KA==0 and KB==0:
    print((H+LA-1)//LA+(W+LB-1)//LB)
    exit()

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**9

    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**9

    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