結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,440 KB
testcase_01 AC 34 ms
52,376 KB
testcase_02 AC 33 ms
52,504 KB
testcase_03 AC 50 ms
66,028 KB
testcase_04 AC 33 ms
52,380 KB
testcase_05 AC 33 ms
52,268 KB
testcase_06 AC 33 ms
53,224 KB
testcase_07 AC 36 ms
53,340 KB
testcase_08 AC 34 ms
52,800 KB
testcase_09 AC 59 ms
68,436 KB
testcase_10 AC 37 ms
54,208 KB
testcase_11 AC 34 ms
53,940 KB
testcase_12 AC 43 ms
61,180 KB
testcase_13 AC 46 ms
63,356 KB
testcase_14 AC 33 ms
53,360 KB
testcase_15 AC 34 ms
53,448 KB
testcase_16 AC 32 ms
53,084 KB
testcase_17 AC 406 ms
69,228 KB
testcase_18 AC 52 ms
61,708 KB
testcase_19 AC 36 ms
52,260 KB
testcase_20 AC 53 ms
65,588 KB
testcase_21 AC 103 ms
70,052 KB
testcase_22 AC 129 ms
61,288 KB
testcase_23 AC 50 ms
62,620 KB
testcase_24 AC 111 ms
65,004 KB
testcase_25 AC 156 ms
62,108 KB
testcase_26 WA -
testcase_27 AC 49 ms
60,404 KB
testcase_28 AC 75 ms
72,652 KB
testcase_29 AC 61 ms
69,496 KB
testcase_30 AC 158 ms
73,156 KB
testcase_31 AC 71 ms
69,880 KB
testcase_32 AC 65 ms
68,724 KB
testcase_33 AC 68 ms
70,320 KB
testcase_34 AC 59 ms
69,188 KB
testcase_35 AC 73 ms
74,060 KB
testcase_36 AC 59 ms
67,856 KB
testcase_37 AC 36 ms
52,480 KB
testcase_38 AC 33 ms
52,672 KB
testcase_39 AC 34 ms
53,340 KB
testcase_40 AC 34 ms
53,692 KB
testcase_41 AC 33 ms
52,312 KB
testcase_42 AC 34 ms
52,944 KB
testcase_43 AC 32 ms
52,576 KB
testcase_44 AC 33 ms
52,692 KB
testcase_45 AC 38 ms
59,676 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**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