結果
問題 |
No.1830 Balanced Majority
|
ユーザー |
|
提出日時 | 2022-02-05 00:11:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 572 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 69,088 KB |
平均クエリ数 | 7.50 |
最終ジャッジ日時 | 2024-06-11 13:11:24 |
合計ジャッジ時間 | 3,076 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
import sys n = int(input()) print('?', 1) sys.stdout.flush() a1 = int(input()) print('?', n - 1) sys.stdout.flush() an = n // 2 - int(input()) if a1 != an: print('!', 2, n - 1) exit() left, right = 1, n for _ in range(18): mid = (left + right) // 2 print('?', mid) sys.stdout.flush() x = int(input()) if an == 0: x = mid - x if x * 2 == mid: right = mid break elif x * 2 < mid: right = mid else: left = mid if right >= n // 2: print('!', 1, right) else: print('!', right + 1, n)