結果
問題 | No.1830 Balanced Majority |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2022-02-05 10:15:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 101 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 87,144 KB |
実行使用メモリ | 87,592 KB |
平均クエリ数 | 8.31 |
最終ジャッジ日時 | 2023-09-02 06:29:37 |
合計ジャッジ時間 | 4,547 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
87,052 KB |
testcase_01 | AC | 93 ms
86,984 KB |
testcase_02 | AC | 94 ms
87,172 KB |
testcase_03 | AC | 93 ms
87,028 KB |
testcase_04 | AC | 96 ms
87,244 KB |
testcase_05 | AC | 95 ms
87,392 KB |
testcase_06 | AC | 94 ms
86,988 KB |
testcase_07 | AC | 96 ms
87,112 KB |
testcase_08 | AC | 97 ms
87,172 KB |
testcase_09 | AC | 99 ms
87,312 KB |
testcase_10 | AC | 99 ms
86,816 KB |
testcase_11 | AC | 98 ms
87,500 KB |
testcase_12 | AC | 97 ms
87,284 KB |
testcase_13 | AC | 96 ms
87,176 KB |
testcase_14 | AC | 97 ms
87,372 KB |
testcase_15 | AC | 95 ms
87,304 KB |
testcase_16 | AC | 97 ms
87,528 KB |
testcase_17 | AC | 100 ms
86,952 KB |
testcase_18 | AC | 96 ms
87,260 KB |
testcase_19 | AC | 96 ms
87,024 KB |
testcase_20 | AC | 98 ms
87,404 KB |
testcase_21 | AC | 101 ms
87,244 KB |
testcase_22 | AC | 100 ms
87,388 KB |
testcase_23 | AC | 101 ms
87,080 KB |
testcase_24 | AC | 97 ms
87,592 KB |
testcase_25 | AC | 95 ms
87,164 KB |
ソースコード
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) dif = 2*a-1 l = 1 r = N-1 while r > l + 1: m = (r+l)//2 re = quenstion(m) if m-re == 0: c = m L,R = 1,c if N-c > c: L,R = c+1,N answer(L,R) else: dif2 = re*2-m if dif*dif2 < 0: r = m else: l = m c = l L,R = 1,c if N-c > c: L,R = c+1,N answer(L,R)