結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
87,584 KB
testcase_01 AC 92 ms
87,104 KB
testcase_02 AC 95 ms
87,448 KB
testcase_03 AC 95 ms
87,268 KB
testcase_04 AC 93 ms
87,276 KB
testcase_05 WA -
testcase_06 AC 93 ms
87,540 KB
testcase_07 AC 95 ms
87,460 KB
testcase_08 AC 93 ms
87,984 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 93 ms
87,228 KB
testcase_13 AC 93 ms
87,156 KB
testcase_14 AC 96 ms
88,012 KB
testcase_15 AC 97 ms
87,296 KB
testcase_16 AC 95 ms
87,592 KB
testcase_17 AC 94 ms
87,128 KB
testcase_18 AC 95 ms
87,652 KB
testcase_19 AC 94 ms
87,668 KB
testcase_20 AC 94 ms
87,288 KB
testcase_21 AC 94 ms
87,592 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 97 ms
87,456 KB
testcase_25 AC 93 ms
87,272 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)
    if s0 == 0:
        print("!", 1, N // 2)
        sys.stdout.flush()
        exit()

    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