結果

問題 No.1830 Balanced Majority
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-02-04 21:40:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 1,114 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 87,876 KB
平均クエリ数 11.15
最終ジャッジ日時 2023-09-02 04:38:12
合計ジャッジ時間 5,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
87,172 KB
testcase_01 AC 91 ms
87,416 KB
testcase_02 AC 91 ms
87,484 KB
testcase_03 AC 93 ms
87,024 KB
testcase_04 AC 95 ms
87,112 KB
testcase_05 AC 93 ms
87,072 KB
testcase_06 WA -
testcase_07 AC 96 ms
87,020 KB
testcase_08 AC 96 ms
87,276 KB
testcase_09 WA -
testcase_10 AC 97 ms
86,848 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 94 ms
87,072 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 95 ms
86,920 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 97 ms
87,244 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

0 110

0 011

"""

import sys
from sys import stdin

def ask(i):

    print ("?",i,flush=True)
    cat = int(stdin.readline())
    assert cat != -1
    return cat

N = int(stdin.readline())

one = ask(1)
two = ask(2)

a1 = one
a2 = two-one
if a1 != a2:
    print ("!",1,2,flush=True)
    sys.exit()

l = 2
r = N

while r-l != 1:

    m = (l+r)//2
    get = ask(m)

    x = get-a1 #one
    y = (m-1)-x #zero

    #print (m,x,y)

    if a2 == 1:
        if x <= y:
            r = m
        else:
            l = m
    else:
        if x >= y:
            r = m
        else:
            l = m

print ("!",2,r,flush=True)
0