結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-05 00:10:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 572 bytes |
| コンパイル時間 | 141 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 70,216 KB |
| 平均クエリ数 | 7.50 |
| 最終ジャッジ日時 | 2024-06-11 13:10:36 |
| 合計ジャッジ時間 | 2,994 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 WA * 3 |
ソースコード
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, 1)