結果

問題 No.1830 Balanced Majority
ユーザー tamatotamato
提出日時 2022-02-04 21:34:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,400 KB
実行使用メモリ 88,112 KB
平均クエリ数 11.38
最終ジャッジ日時 2023-09-02 04:33:21
合計ジャッジ時間 4,678 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
87,956 KB
testcase_01 AC 94 ms
87,108 KB
testcase_02 AC 93 ms
87,032 KB
testcase_03 AC 94 ms
87,480 KB
testcase_04 AC 93 ms
87,028 KB
testcase_05 WA -
testcase_06 AC 94 ms
87,252 KB
testcase_07 AC 95 ms
87,428 KB
testcase_08 AC 94 ms
87,860 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 95 ms
88,016 KB
testcase_13 AC 96 ms
87,600 KB
testcase_14 AC 97 ms
86,948 KB
testcase_15 AC 96 ms
87,288 KB
testcase_16 AC 95 ms
87,180 KB
testcase_17 AC 94 ms
87,516 KB
testcase_18 AC 94 ms
87,756 KB
testcase_19 AC 95 ms
87,252 KB
testcase_20 AC 93 ms
87,416 KB
testcase_21 AC 96 ms
87,676 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 96 ms
87,448 KB
testcase_25 AC 92 ms
87,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def ask(k):
        print("?", k)
        sys.stdout.flush()
        return int(input())

    N = int(input())

    s0 = ask(N // 2)
    if s0 * 2 == N or s0 == 0:
        print("!", 2, N - 1)
        sys.stdout.flush()
        exit()
    s0 = s0 - (N // 2 - s0)

    l = N // 2
    r = N + 1
    for _ in range(19):
        mid = (l + r) // 2
        s = ask(mid)
        s = s - (mid - s)
        if s == 0:
            print("!", 1, mid)
            sys.stdout.flush()
            exit()
        if s * s0 > 0:
            l = mid
        else:
            r = mid


if __name__ == '__main__':
    main()
0