結果

問題 No.1830 Balanced Majority
ユーザー tamatotamato
提出日時 2022-02-04 21:47:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 87,600 KB
実行使用メモリ 88,184 KB
平均クエリ数 15.27
最終ジャッジ日時 2023-09-02 04:41:13
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 94 ms
87,832 KB
testcase_02 WA -
testcase_03 AC 94 ms
88,016 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 94 ms
87,852 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 95 ms
87,880 KB
testcase_12 AC 96 ms
87,740 KB
testcase_13 AC 97 ms
87,408 KB
testcase_14 AC 100 ms
87,632 KB
testcase_15 AC 96 ms
87,296 KB
testcase_16 AC 97 ms
87,716 KB
testcase_17 AC 98 ms
87,956 KB
testcase_18 AC 96 ms
87,688 KB
testcase_19 AC 95 ms
87,708 KB
testcase_20 AC 95 ms
87,792 KB
testcase_21 AC 96 ms
87,316 KB
testcase_22 AC 97 ms
87,500 KB
testcase_23 AC 97 ms
87,528 KB
testcase_24 AC 99 ms
87,436 KB
testcase_25 AC 96 ms
87,192 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(1)
    s1 = ask(N - 1)
    if s0 == s1:
        print("!", 2, N - 1)
        sys.stdout.flush()
        exit()
    s0 = s0 - (1 - s0)
    s1 = s1 - (N - 1 - s1)
    ll = s0
    rr = s1

    l = 1
    r = N - 1
    for _ in range(18):
        mid = (l + r) // 2
        s = ask(mid)
        s = s - (mid - s)
        if s == 0:
            if mid < N // 2:
                print("!", mid + 1, N)
            else:
                print("!", 1, mid)
            sys.stdout.flush()
            exit()
        if s // abs(s) == ll:
            l = mid
        else:
            r = mid


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