結果
問題 | No.1830 Balanced Majority |
ユーザー | 👑 Kazun |
提出日時 | 2022-02-05 09:57:45 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 941 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 87,336 KB |
実行使用メモリ | 89,232 KB |
平均クエリ数 | 8.19 |
最終ジャッジ日時 | 2023-09-02 06:28:35 |
合計ジャッジ時間 | 4,664 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
87,060 KB |
testcase_01 | AC | 94 ms
87,672 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 92 ms
87,036 KB |
testcase_05 | AC | 96 ms
87,692 KB |
testcase_06 | WA | - |
testcase_07 | AC | 98 ms
89,152 KB |
testcase_08 | AC | 99 ms
88,972 KB |
testcase_09 | AC | 97 ms
89,224 KB |
testcase_10 | AC | 98 ms
88,280 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 99 ms
89,004 KB |
testcase_15 | AC | 98 ms
88,904 KB |
testcase_16 | AC | 99 ms
88,856 KB |
testcase_17 | AC | 100 ms
88,768 KB |
testcase_18 | AC | 96 ms
88,348 KB |
testcase_19 | AC | 95 ms
87,384 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
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)