結果
問題 | No.1830 Balanced Majority |
ユーザー |
|
提出日時 | 2023-03-08 01:04:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 759 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 72,808 KB |
平均クエリ数 | 7.31 |
最終ジャッジ日時 | 2024-09-18 02:21:39 |
合計ジャッジ時間 | 4,356 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 17 WA * 8 |
ソースコード
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 abs(ok - ng) > 1: 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 == a: ng = mid else: ok = mid