結果

問題 No.1830 Balanced Majority
ユーザー lloyzlloyz
提出日時 2022-02-05 00:11:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 87,520 KB
平均クエリ数 7.50
最終ジャッジ日時 2023-09-02 06:15:27
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
87,052 KB
testcase_01 AC 96 ms
87,224 KB
testcase_02 AC 96 ms
87,444 KB
testcase_03 AC 97 ms
87,100 KB
testcase_04 AC 96 ms
87,396 KB
testcase_05 AC 96 ms
86,744 KB
testcase_06 AC 98 ms
87,372 KB
testcase_07 AC 98 ms
86,896 KB
testcase_08 AC 96 ms
86,860 KB
testcase_09 AC 97 ms
87,060 KB
testcase_10 AC 96 ms
87,156 KB
testcase_11 AC 99 ms
87,008 KB
testcase_12 AC 97 ms
87,328 KB
testcase_13 AC 99 ms
87,220 KB
testcase_14 AC 98 ms
87,480 KB
testcase_15 AC 99 ms
87,344 KB
testcase_16 AC 98 ms
87,176 KB
testcase_17 AC 99 ms
87,320 KB
testcase_18 AC 97 ms
87,012 KB
testcase_19 AC 97 ms
86,844 KB
testcase_20 AC 97 ms
86,988 KB
testcase_21 AC 97 ms
87,520 KB
testcase_22 AC 99 ms
86,868 KB
testcase_23 AC 99 ms
87,040 KB
testcase_24 AC 99 ms
87,024 KB
testcase_25 AC 96 ms
87,200 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, n)
0