結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
ikoma
|
| 提出日時 | 2022-02-04 22:40:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 342 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 69,344 KB |
| 平均クエリ数 | 7.50 |
| 最終ジャッジ日時 | 2024-06-11 12:11:29 |
| 合計ジャッジ時間 | 3,468 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 25 |
ソースコード
N=int(input())
def request(k):
print(f"? {k}", flush=True)
return int(input())*2-k
sign = lambda x:(1 if x>0 else (0 if x==0 else -1))
ans1 = request(1)
ansnm1 = request(N-1)
if ans1==ansnm1:
print(f"! 1 {N-1}", flush=True)
exit()
l,r = 1,N
la,ra = ans1,N//2
while l+1<r:
m = (l+r)//2
ans = request(m)
if ans==0:
break
if sign(ans)*sign(la) < 0:
r = m
ra = ans
else:
l = m
la = ans
if ans <= N//2:
print(f"! {ans} {N}", flush=True)
else:
print(f"! {1} {ans}", flush=True)
ikoma