結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
87,716 KB
testcase_01 AC 94 ms
87,420 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 93 ms
87,144 KB
testcase_05 AC 94 ms
87,476 KB
testcase_06 WA -
testcase_07 AC 95 ms
87,020 KB
testcase_08 AC 94 ms
87,364 KB
testcase_09 AC 96 ms
87,492 KB
testcase_10 AC 93 ms
87,780 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 96 ms
87,100 KB
testcase_15 AC 97 ms
87,232 KB
testcase_16 AC 98 ms
87,336 KB
testcase_17 AC 97 ms
86,976 KB
testcase_18 AC 96 ms
87,408 KB
testcase_19 AC 96 ms
86,868 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 = 0
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



    
0