結果
問題 |
No.1830 Balanced Majority
|
ユーザー |
👑 ![]() |
提出日時 | 2022-02-05 10:01:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 941 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 71,328 KB |
平均クエリ数 | 8.27 |
最終ジャッジ日時 | 2024-06-11 13:23:00 |
合計ジャッジ時間 | 3,193 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 WA * 2 |
ソースコード
def question(K): print("?",K,flush=True) S=int(input()) T[K]=S-(K-S) def answer(L,R): print("!",L,R,flush=True) exit() def General_Binary_Increase_Search_Integer(L,R,cond,default=None): """条件式が単調増加であるとき, 整数上で二部探索を行う. L: 解の下限 R: 解の上限 cond: 条件(1変数関数, 広義単調増加を満たす) default: Lで条件を満たさないときの返り値 """ #if not(cond(R)): return default #if cond(L): return L R+=1 while R-L>1: C=L+(R-L)//2 if cond(C): R=C else: L=C return R def check(x): question(x) return T[x]*T[N-1]>=0 #================================================== N=int(input()) T=[None]*(N+1) question(1); question(N-1) if T[1]==T[N-1]: answer(2,N-1) M=General_Binary_Increase_Search_Integer(2,N-1,check) if N//2<=M: answer(1,M) else: answer(M+1,N)