結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー ikomaikoma
提出日時 2022-10-14 22:01:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 86,828 KB
実行使用メモリ 76,500 KB
最終ジャッジ日時 2023-09-08 21:26:59
合計ジャッジ時間 12,831 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
75,680 KB
testcase_01 AC 141 ms
75,680 KB
testcase_02 AC 137 ms
75,716 KB
testcase_03 AC 129 ms
75,848 KB
testcase_04 AC 137 ms
75,620 KB
testcase_05 AC 145 ms
75,568 KB
testcase_06 AC 137 ms
75,868 KB
testcase_07 AC 131 ms
75,704 KB
testcase_08 AC 139 ms
75,744 KB
testcase_09 AC 131 ms
75,776 KB
testcase_10 AC 138 ms
75,716 KB
testcase_11 AC 130 ms
75,780 KB
testcase_12 AC 132 ms
75,740 KB
testcase_13 AC 130 ms
75,640 KB
testcase_14 AC 135 ms
75,652 KB
testcase_15 AC 141 ms
75,680 KB
testcase_16 AC 135 ms
75,660 KB
testcase_17 AC 129 ms
75,792 KB
testcase_18 AC 138 ms
75,816 KB
testcase_19 AC 140 ms
75,688 KB
testcase_20 AC 141 ms
75,736 KB
testcase_21 AC 134 ms
75,712 KB
testcase_22 AC 131 ms
75,832 KB
testcase_23 AC 131 ms
75,848 KB
testcase_24 AC 137 ms
75,744 KB
testcase_25 AC 136 ms
75,736 KB
testcase_26 AC 138 ms
75,892 KB
testcase_27 AC 125 ms
75,880 KB
testcase_28 AC 127 ms
75,680 KB
testcase_29 AC 133 ms
75,364 KB
testcase_30 AC 141 ms
75,680 KB
testcase_31 AC 134 ms
75,672 KB
testcase_32 AC 130 ms
75,572 KB
testcase_33 AC 132 ms
75,752 KB
testcase_34 AC 133 ms
75,512 KB
testcase_35 AC 140 ms
75,712 KB
testcase_36 AC 133 ms
75,680 KB
testcase_37 AC 129 ms
75,936 KB
testcase_38 AC 133 ms
75,892 KB
testcase_39 AC 137 ms
75,740 KB
testcase_40 AC 134 ms
75,572 KB
testcase_41 AC 130 ms
75,744 KB
testcase_42 AC 134 ms
75,784 KB
testcase_43 AC 130 ms
75,844 KB
testcase_44 AC 132 ms
75,676 KB
testcase_45 AC 138 ms
75,532 KB
testcase_46 AC 130 ms
75,888 KB
testcase_47 AC 133 ms
75,668 KB
testcase_48 AC 130 ms
75,476 KB
testcase_49 AC 138 ms
75,808 KB
testcase_50 AC 141 ms
75,772 KB
testcase_51 AC 134 ms
75,516 KB
testcase_52 AC 129 ms
75,664 KB
testcase_53 AC 139 ms
75,732 KB
testcase_54 AC 143 ms
75,736 KB
testcase_55 AC 738 ms
76,500 KB
testcase_56 AC 111 ms
75,428 KB
testcase_57 AC 135 ms
75,820 KB
testcase_58 AC 135 ms
75,740 KB
testcase_59 AC 131 ms
75,732 KB
testcase_60 AC 124 ms
75,672 KB
testcase_61 AC 130 ms
75,668 KB
testcase_62 AC 123 ms
75,776 KB
testcase_63 AC 130 ms
75,828 KB
testcase_64 AC 135 ms
75,820 KB
testcase_65 AC 112 ms
75,644 KB
testcase_66 AC 134 ms
75,616 KB
testcase_67 AC 110 ms
75,888 KB
testcase_68 AC 142 ms
75,740 KB
testcase_69 AC 130 ms
75,676 KB
testcase_70 AC 141 ms
75,668 KB
testcase_71 AC 133 ms
75,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
X,A=map(int,input().split())
Y,B=map(int,input().split())

def calc(na:int):
    x = A*na
    t=X*na
    if x <= T:
        return (T-x) + t
    d = x-T
    nb = (d+B-1)//B
    t += Y*nb
    x -= B*nb
    return t + (T-x)


low = 0
high = 10**12
ans = 10**20

while low<high:
    c1 = (low*2+high)//3
    c2 = (low+high*2)//3

    t1 = calc(c1)
    t2 = calc(c2)

    if t1<t2:
        if high==c2:break
        high = c2
        ans = min(ans, t1)
    else:
        if low==c1:break
        ans = min(ans, t2)
        low = c1

for i in range(10**7):
    t = calc(i)
    ans = min(ans, t)

print(ans)
0