結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー 👑 H20H20
提出日時 2022-10-14 23:24:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,924 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 71,940 KB
最終ジャッジ日時 2023-09-08 23:47:13
合計ジャッジ時間 8,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,568 KB
testcase_01 AC 77 ms
71,588 KB
testcase_02 AC 75 ms
71,460 KB
testcase_03 WA -
testcase_04 AC 74 ms
71,440 KB
testcase_05 AC 74 ms
71,564 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 72 ms
71,560 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 73 ms
71,564 KB
testcase_15 AC 72 ms
71,432 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 72 ms
71,668 KB
testcase_19 AC 72 ms
71,456 KB
testcase_20 AC 72 ms
71,460 KB
testcase_21 AC 72 ms
71,836 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 72 ms
71,320 KB
testcase_25 AC 72 ms
71,668 KB
testcase_26 AC 72 ms
71,496 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 73 ms
71,572 KB
testcase_30 AC 71 ms
71,896 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 70 ms
71,420 KB
testcase_35 AC 70 ms
71,436 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 73 ms
71,516 KB
testcase_39 AC 70 ms
71,592 KB
testcase_40 AC 73 ms
71,844 KB
testcase_41 WA -
testcase_42 AC 72 ms
71,568 KB
testcase_43 AC 72 ms
71,420 KB
testcase_44 AC 73 ms
71,596 KB
testcase_45 AC 72 ms
71,564 KB
testcase_46 WA -
testcase_47 AC 74 ms
71,836 KB
testcase_48 WA -
testcase_49 AC 72 ms
71,400 KB
testcase_50 AC 72 ms
71,508 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 73 ms
71,260 KB
testcase_54 AC 71 ms
71,900 KB
testcase_55 AC 73 ms
71,852 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 AC 72 ms
71,568 KB
testcase_65 AC 72 ms
71,572 KB
testcase_66 AC 70 ms
71,400 KB
testcase_67 AC 71 ms
71,564 KB
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 AC 72 ms
71,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
三分探索の抽象化ライブラリ
domain:= 定義域が整数(0)or実数(1)
searchtype:= 狭義に凹で最大値を求めたい(0)or狭義に凸で最小値を求めたい(1)
f:= 最大または最小にしたい値を返す
l,r:= 探索範囲(l<=r)
eps:= 誤差(整数なら2,実数なら誤差指定による)
iter:= 探索回数
op1:= 割り算の演算子
op2:= 反転させるかどうか(0の時反転)
op3:= 出力での反転
value:= 三分探索の解
args:= fの引数(iterable)…f(i,args)という形でargsを展開
'''
from operator import floordiv,truediv,truth,not_
from math import log
class ternary_search:
    def __init__(self,domain,searchtype,f,l,r,eps,args=None):
        self.domain=domain
        self.searchtype=searchtype
        self.f=f
        self.l,self.r=l,r
        self.iter=int(log((r+1-l)/eps,1.5))+5
        self.args=args
        self.op1=[floordiv,truediv][domain]
        self.op2=[not_,truth][searchtype]
        self.op3=[max,min][searchtype]
        self.value=self.calc()
    def calc(self):
        for _ in range(self.iter):
            diff=self.op1(self.r-self.l,3)
            trisection1=self.l+diff
            trisection2=self.r-diff
            trisection1_value=self.f(trisection1,self.args)
            trisection2_value=self.f(trisection2,self.args)
            if self.op2(trisection1_value<=trisection2_value):
                self.r=trisection2
            if self.op2(trisection1_value>=trisection2_value):
                self.l=trisection1
        return self.op3([self.l,self.l+self.op1(self.r-self.l,2),self.r],key=lambda x:self.f(x,self.args))



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


def f(y,arg):
    day = -y*B
    if T>=day:
        x = (T-day)//A
        return min(y*Y+(T-day),y*Y+x*X+abs(T-(y*A-x*B)))
    else:
        return 10**20-y
e=ternary_search(0,1,f,0,10**18,2)
print(f(e.value,None))

0