結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2022-02-04 21:35:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 791 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 83,072 KB |
| 実行使用メモリ | 69,472 KB |
| 平均クエリ数 | 10.50 |
| 最終ジャッジ日時 | 2024-06-11 11:33:01 |
| 合計ジャッジ時間 | 3,543 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 WA * 6 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
def ask(k):
print("?", k)
sys.stdout.flush()
return int(input())
N = int(input())
s0 = ask(N // 2)
if s0 * 2 == N or s0 == 0:
print("!", 2, N - 1)
sys.stdout.flush()
exit()
s0 = s0 - (N // 2 - s0)
if s0 == 0:
print("!", 1, N // 2)
sys.stdout.flush()
exit()
l = N // 2
r = N + 1
for _ in range(19):
mid = (l + r) // 2
s = ask(mid)
s = s - (mid - s)
if s == 0:
print("!", 1, mid)
sys.stdout.flush()
exit()
if s * s0 > 0:
l = mid
else:
r = mid
if __name__ == '__main__':
main()
tamato