結果
問題 |
No.1830 Balanced Majority
|
ユーザー |
|
提出日時 | 2022-02-05 10:10:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 587 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 69,344 KB |
平均クエリ数 | 6.69 |
最終ジャッジ日時 | 2024-06-11 13:23:19 |
合計ジャッジ時間 | 3,157 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 16 WA * 9 |
ソースコード
import sys ##入力 N = int(input()) ##質問 def quenstion(K): print("? {}".format(K)) sys.stdout.flush() return int(input()) ##回答 def answer(L,R): print("! {} {}".format(L,R)) sys.stdout.flush() exit() a = quenstion(1) n1 = quenstion(N-1) if 2*a-1 == 2*n1-N+1: answer(2,N-1) l = 1 r = N-1 while r > l + 1: m = (r+l)//2 r = quenstion(m) if m-r == 0: c = m L,R = 1,c if N-c > c: L,R = c,N answer(L,R) else: r = m c = r L,R = 1,c if N-c > c: L,R = c,N answer(L,R)