結果
問題 |
No.1830 Balanced Majority
|
ユーザー |
![]() |
提出日時 | 2022-02-04 21:34:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 69,472 KB |
平均クエリ数 | 11.38 |
最終ジャッジ日時 | 2024-06-11 11:31:38 |
合計ジャッジ時間 | 3,653 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 WA * 6 |
ソースコード
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) 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()