結果

問題 No.1830 Balanced Majority
ユーザー ShirotsumeShirotsume
提出日時 2023-03-08 01:07:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 748 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 82,224 KB
平均クエリ数 8.35
最終ジャッジ日時 2023-10-18 05:44:23
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,920 KB
testcase_01 AC 63 ms
71,920 KB
testcase_02 AC 62 ms
71,920 KB
testcase_03 AC 67 ms
71,920 KB
testcase_04 AC 63 ms
71,920 KB
testcase_05 AC 64 ms
71,920 KB
testcase_06 AC 64 ms
71,920 KB
testcase_07 AC 66 ms
71,912 KB
testcase_08 AC 64 ms
71,912 KB
testcase_09 AC 65 ms
71,912 KB
testcase_10 AC 65 ms
71,912 KB
testcase_11 RE -
testcase_12 AC 64 ms
71,916 KB
testcase_13 RE -
testcase_14 AC 66 ms
71,916 KB
testcase_15 AC 64 ms
71,916 KB
testcase_16 AC 66 ms
71,916 KB
testcase_17 AC 65 ms
71,916 KB
testcase_18 AC 64 ms
71,916 KB
testcase_19 AC 64 ms
71,916 KB
testcase_20 RE -
testcase_21 AC 65 ms
71,916 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 63 ms
71,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

def query(x):
    print('?', x, flush=True)
    p = ii()
    return 2 * p - x
def ans(l, r):
    print('!', l, r, flush=True)

a = query(1)
b = query(n - 1)
if a == b:
    ans(2, n - 1)
else:
    ng = n - 1
    ok = 1
    while True:
        mid = (ok + ng) // 2
        p = query(mid)
        if p == 0:
            if mid >= n // 2:
                ans(1, mid)
            else:
                ans(mid + 1, n)
            exit()
        elif p == b:
            ng = mid
        else:
            ok = mid

        
0