結果

問題 No.1830 Balanced Majority
ユーザー 👑 KazunKazun
提出日時 2022-02-05 10:05:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 89,304 KB
平均クエリ数 7.69
最終ジャッジ日時 2023-09-02 06:28:57
合計ジャッジ時間 4,685 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
87,688 KB
testcase_01 AC 91 ms
87,764 KB
testcase_02 AC 92 ms
87,608 KB
testcase_03 AC 92 ms
87,692 KB
testcase_04 AC 91 ms
86,928 KB
testcase_05 AC 92 ms
87,212 KB
testcase_06 AC 91 ms
86,816 KB
testcase_07 AC 97 ms
88,884 KB
testcase_08 AC 96 ms
88,728 KB
testcase_09 AC 95 ms
88,552 KB
testcase_10 AC 97 ms
88,740 KB
testcase_11 AC 98 ms
88,556 KB
testcase_12 AC 95 ms
88,948 KB
testcase_13 AC 96 ms
88,768 KB
testcase_14 AC 98 ms
88,620 KB
testcase_15 AC 99 ms
88,696 KB
testcase_16 AC 99 ms
89,108 KB
testcase_17 AC 98 ms
88,512 KB
testcase_18 AC 95 ms
87,884 KB
testcase_19 AC 94 ms
87,428 KB
testcase_20 AC 93 ms
87,564 KB
testcase_21 AC 98 ms
89,304 KB
testcase_22 AC 100 ms
89,164 KB
testcase_23 AC 101 ms
88,756 KB
testcase_24 AC 101 ms
88,468 KB
testcase_25 AC 95 ms
87,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()

#==================================================
N=int(input())
T=[None]*(N+1)

question(1); question(N-1)

if T[1]==T[N-1]:
    answer(2,N-1)

L,R=1,N-1
while True:
    C=(L+R)//2
    question(C)
    if T[C]==0:
        break
    elif T[C]*T[N-1]>0:
        R=C
    else:
        L=C+1

if N//2<=C:
    answer(1,C)
else:
    answer(C+1,N)
0