結果

問題 No.1286 Stone Skipping
ユーザー FromBooskaFromBooska
提出日時 2023-02-15 20:46:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 75,840 KB
最終ジャッジ日時 2023-09-25 04:52:41
合計ジャッジ時間 7,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,484 KB
testcase_01 AC 69 ms
71,260 KB
testcase_02 AC 73 ms
75,724 KB
testcase_03 AC 69 ms
71,400 KB
testcase_04 AC 74 ms
71,260 KB
testcase_05 AC 70 ms
71,260 KB
testcase_06 AC 71 ms
71,232 KB
testcase_07 AC 70 ms
71,220 KB
testcase_08 AC 71 ms
71,196 KB
testcase_09 AC 70 ms
71,104 KB
testcase_10 AC 71 ms
71,368 KB
testcase_11 AC 70 ms
71,340 KB
testcase_12 AC 71 ms
71,488 KB
testcase_13 AC 73 ms
75,480 KB
testcase_14 AC 73 ms
75,744 KB
testcase_15 AC 74 ms
75,416 KB
testcase_16 AC 73 ms
75,488 KB
testcase_17 AC 71 ms
75,696 KB
testcase_18 AC 69 ms
71,492 KB
testcase_19 AC 68 ms
71,300 KB
testcase_20 AC 73 ms
75,632 KB
testcase_21 AC 71 ms
75,728 KB
testcase_22 AC 74 ms
75,840 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

D = int(input())

# むむむ、二分探索と思ったらDにぴったり止まる必要ある
# つまり行き過ぎてはダメなので二分探索ではダメか
# その数が辿り着く数列を考える必要あるか

def max_distance(num):
    dist = 0
    reached = []
    while num >= 1:
        dist += num
        num //= 2
        reached.append(dist)
    return dist, reached

OK = D+1
NG = 0
while OK-NG>1:
    mid = (OK+NG)//2
    if max_distance(mid)[0] >= D:
        OK = mid
    else:
        NG = mid

candidate = OK
while True:
    if D in max_distance(candidate)[1]:
        print(candidate)
        break
    else:
        candidate += 1

0