結果
問題 | No.1830 Balanced Majority |
ユーザー | 👑 Kazun |
提出日時 | 2022-02-05 10:02:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 87,136 KB |
実行使用メモリ | 89,288 KB |
平均クエリ数 | 8.65 |
最終ジャッジ日時 | 2023-09-02 06:28:46 |
合計ジャッジ時間 | 4,687 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
87,380 KB |
testcase_01 | AC | 99 ms
87,464 KB |
testcase_02 | AC | 94 ms
87,172 KB |
testcase_03 | AC | 96 ms
87,176 KB |
testcase_04 | AC | 97 ms
87,104 KB |
testcase_05 | AC | 97 ms
86,824 KB |
testcase_06 | AC | 95 ms
87,232 KB |
testcase_07 | AC | 102 ms
88,380 KB |
testcase_08 | AC | 99 ms
88,436 KB |
testcase_09 | AC | 100 ms
88,432 KB |
testcase_10 | AC | 101 ms
89,288 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 103 ms
89,260 KB |
testcase_14 | AC | 101 ms
88,516 KB |
testcase_15 | AC | 101 ms
88,240 KB |
testcase_16 | AC | 103 ms
89,024 KB |
testcase_17 | AC | 101 ms
88,552 KB |
testcase_18 | AC | 95 ms
87,104 KB |
testcase_19 | AC | 97 ms
87,220 KB |
testcase_20 | AC | 95 ms
87,044 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 103 ms
88,592 KB |
testcase_24 | WA | - |
testcase_25 | AC | 98 ms
87,488 KB |
ソースコード
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)