結果

問題 No.1830 Balanced Majority
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-02-05 10:10:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 87,772 KB
平均クエリ数 6.69
最終ジャッジ日時 2023-09-02 06:29:07
合計ジャッジ時間 4,501 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
87,332 KB
testcase_01 AC 98 ms
87,240 KB
testcase_02 AC 97 ms
87,020 KB
testcase_03 AC 96 ms
87,204 KB
testcase_04 AC 96 ms
87,548 KB
testcase_05 AC 96 ms
87,032 KB
testcase_06 WA -
testcase_07 AC 93 ms
87,404 KB
testcase_08 AC 92 ms
87,060 KB
testcase_09 AC 93 ms
87,548 KB
testcase_10 AC 95 ms
87,720 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 97 ms
87,284 KB
testcase_15 AC 98 ms
86,880 KB
testcase_16 AC 97 ms
87,340 KB
testcase_17 AC 98 ms
87,028 KB
testcase_18 AC 98 ms
87,060 KB
testcase_19 AC 94 ms
87,268 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

##入力
N = int(input())

##質問
def quenstion(K):
    print("? {}".format(K))
    sys.stdout.flush()
    return int(input())

##回答
def answer(L,R):
    print("! {} {}".format(L,R))
    sys.stdout.flush()
    exit()

a = quenstion(1)
n1 = quenstion(N-1)
if 2*a-1 == 2*n1-N+1:
    answer(2,N-1)

l = 1
r = N-1
while r > l + 1:
    m = (r+l)//2

    r = quenstion(m)
    if m-r == 0:
        c = m
        L,R = 1,c
        if N-c > c:
            L,R = c,N
        answer(L,R)
        
    else:
        r = m

c = r
L,R = 1,c
if N-c > c:
    L,R = c,N
answer(L,R)
    
0