結果

問題 No.1830 Balanced Majority
ユーザー first_vilfirst_vil
提出日時 2022-02-04 23:11:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 1,254 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 87,856 KB
平均クエリ数 15.73
最終ジャッジ日時 2023-09-02 05:48:43
合計ジャッジ時間 6,175 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 97 ms
86,888 KB
testcase_02 AC 98 ms
87,416 KB
testcase_03 AC 96 ms
86,848 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 98 ms
87,360 KB
testcase_13 AC 99 ms
87,076 KB
testcase_14 AC 98 ms
87,076 KB
testcase_15 AC 97 ms
86,928 KB
testcase_16 AC 98 ms
87,080 KB
testcase_17 AC 96 ms
87,400 KB
testcase_18 AC 96 ms
87,056 KB
testcase_19 AC 94 ms
87,500 KB
testcase_20 WA -
testcase_21 AC 98 ms
86,960 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 99 ms
86,900 KB
testcase_25 AC 95 ms
87,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353


def ask(k):
    print("?", k)
    sys.stdout.flush()
    return ii()


n = ii()
lim = 20
l, r = 1, n
for _ in range(lim):
    m = (l + r) // 2
    x = ask(m)
    if x * 2 == m:
        r = m
        break
    elif x * 2 < m:
        r = m
    elif x * 2 > m:
        l = m
if n // 2 <= r:
    print("!", 1, r)
else:
    print("!", r + 1, n)
0