結果

問題 No.1830 Balanced Majority
ユーザー lloyzlloyz
提出日時 2022-02-05 00:10:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 87,484 KB
平均クエリ数 7.50
最終ジャッジ日時 2023-09-02 06:14:54
合計ジャッジ時間 4,982 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
87,136 KB
testcase_01 AC 96 ms
87,264 KB
testcase_02 AC 95 ms
87,152 KB
testcase_03 AC 95 ms
87,456 KB
testcase_04 AC 96 ms
87,320 KB
testcase_05 AC 96 ms
86,988 KB
testcase_06 AC 97 ms
86,852 KB
testcase_07 AC 98 ms
86,752 KB
testcase_08 AC 98 ms
86,560 KB
testcase_09 AC 97 ms
87,348 KB
testcase_10 AC 97 ms
87,116 KB
testcase_11 WA -
testcase_12 AC 99 ms
87,248 KB
testcase_13 AC 99 ms
87,196 KB
testcase_14 AC 99 ms
87,196 KB
testcase_15 AC 99 ms
86,780 KB
testcase_16 AC 98 ms
87,100 KB
testcase_17 AC 99 ms
87,284 KB
testcase_18 AC 95 ms
86,732 KB
testcase_19 AC 96 ms
87,484 KB
testcase_20 AC 95 ms
87,192 KB
testcase_21 AC 99 ms
86,916 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 99 ms
86,928 KB
testcase_25 AC 96 ms
86,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

n = int(input())

print('?', 1)
sys.stdout.flush()
a1 = int(input())

print('?', n - 1)
sys.stdout.flush()
an = n // 2 - int(input())

if a1 != an:
    print('!', 2, n - 1)
    exit()

left, right = 1, n
for _ in range(18):
    mid = (left + right) // 2
    print('?', mid)
    sys.stdout.flush()
    x = int(input())
    if an == 0:
        x = mid - x
    if x * 2 == mid:
        right = mid
        break
    elif x * 2 < mid:
        right = mid
    else:
        left = mid
if right >= n // 2:
    print('!', 1, right)
else:
    print('!', right + 1, 1)
0