結果

問題 No.253 ロウソクの長さ
ユーザー convexineqconvexineq
提出日時 2020-12-11 07:05:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 87,724 KB
平均クエリ数 56.39
最終ジャッジ日時 2023-09-24 09:23:59
合計ジャッジ時間 9,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 100 ms
87,204 KB
testcase_02 AC 104 ms
87,484 KB
testcase_03 AC 99 ms
86,948 KB
testcase_04 AC 99 ms
86,756 KB
testcase_05 AC 100 ms
87,392 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 97 ms
86,836 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 98 ms
87,024 KB
testcase_15 AC 103 ms
87,620 KB
testcase_16 AC 97 ms
87,544 KB
testcase_17 AC 96 ms
87,176 KB
testcase_18 WA -
testcase_19 AC 100 ms
86,892 KB
testcase_20 WA -
testcase_21 AC 100 ms
87,132 KB
testcase_22 AC 98 ms
87,108 KB
testcase_23 WA -
testcase_24 AC 104 ms
87,172 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 97 ms
87,016 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def ask(k,t):
    print(f"? {k}")
    sys.stdout.flush()
    if DEBUG:
        if X-t < k: return -1
        elif k==X-t: return 0
        return 1
    else:
        return int(input())

def ans(k):
    print(f"! {k}")
    exit()

import sys
DEBUG = 0
if DEBUG: X = 100

a = ask(100,0)
if a==0:
    ans(100)
if a == -1:
    for t in range(1,100):
        a = ask(9,t)
        if a==0:
            ans(t+9)
for t in range(1,100):
    ng = 100
    ok = 10**9+1
    while ok-ng > 1:
        mid = (ok+ng)//2
        a = ask(mid-t,t)
        if a == -1:
            ok = mid
        elif a == 1:
            ng = mid
        else:
            ans(mid)
0