結果

問題 No.1830 Balanced Majority
ユーザー ShirotsumeShirotsume
提出日時 2023-03-08 01:09:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 1,090 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 72,212 KB
平均クエリ数 8.12
最終ジャッジ日時 2023-10-18 05:45:04
合計ジャッジ時間 4,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,864 KB
testcase_01 AC 65 ms
71,864 KB
testcase_02 AC 62 ms
71,864 KB
testcase_03 AC 64 ms
71,864 KB
testcase_04 AC 64 ms
71,864 KB
testcase_05 AC 63 ms
71,864 KB
testcase_06 AC 63 ms
71,864 KB
testcase_07 AC 65 ms
71,856 KB
testcase_08 AC 64 ms
71,856 KB
testcase_09 AC 64 ms
71,856 KB
testcase_10 AC 63 ms
71,856 KB
testcase_11 WA -
testcase_12 AC 64 ms
71,856 KB
testcase_13 WA -
testcase_14 AC 66 ms
71,856 KB
testcase_15 AC 66 ms
71,856 KB
testcase_16 AC 66 ms
71,856 KB
testcase_17 AC 66 ms
71,856 KB
testcase_18 AC 64 ms
71,856 KB
testcase_19 AC 64 ms
71,856 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 63 ms
71,856 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
    ok = 1
    for _ in range(18):
        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
    if ok >= n // 2:
        ans(1, ok)
    else:
        ans(ok + 1, n)

        
0