結果

問題 No.253 ロウソクの長さ
ユーザー maninimanini
提出日時 2021-02-12 15:30:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 87,948 KB
平均クエリ数 35.08
最終ジャッジ日時 2023-09-24 09:46:07
合計ジャッジ時間 9,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 100 ms
87,024 KB
testcase_02 AC 102 ms
87,096 KB
testcase_03 AC 100 ms
87,600 KB
testcase_04 AC 96 ms
87,264 KB
testcase_05 AC 101 ms
87,188 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 95 ms
87,732 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 101 ms
86,892 KB
testcase_15 AC 103 ms
87,340 KB
testcase_16 AC 101 ms
87,336 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 100 ms
87,272 KB
testcase_20 WA -
testcase_21 AC 98 ms
86,912 KB
testcase_22 AC 98 ms
87,060 KB
testcase_23 WA -
testcase_24 AC 104 ms
86,884 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,040 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')

# 二分探索
imin = 0
imax = 10 ** 9 + 1

print("? {}".format(99))
check = int(input())

if check == 0:
    print("! {}".format(99))

elif check == -1:
    time = 1
    while True:
        print("? {}".format(0))
        check = int(input())

        if check == 0:
            break

        time += 1

    print("! {}".format(time))

elif check == 1:
    time = 0
    while True:
        imid = imin + (imax - imin) // 2

        print("? {}".format(imid - time))
        check = int(input())

        # 2分探索する。
        if check == 0:
            res = imid
            break
        elif check == 1:
            imin = imid
        else:
            imax = imid

        time += 1

    print("! {}".format(res))
0