結果

問題 No.1830 Balanced Majority
ユーザー 👑 Kazun
提出日時 2022-02-05 10:05:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 70,752 KB
平均クエリ数 7.69
最終ジャッジ日時 2024-06-11 13:23:11
合計ジャッジ時間 3,558 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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