結果
問題 | No.1830 Balanced Majority |
ユーザー | titia |
提出日時 | 2022-02-06 00:47:25 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 10,956 KB |
実行使用メモリ | 24,488 KB |
平均クエリ数 | 7.42 |
最終ジャッジ日時 | 2023-09-02 06:53:59 |
合計ジャッジ時間 | 3,115 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
24,100 KB |
testcase_01 | AC | 38 ms
24,048 KB |
testcase_02 | AC | 39 ms
23,844 KB |
testcase_03 | AC | 39 ms
23,856 KB |
testcase_04 | AC | 38 ms
24,216 KB |
testcase_05 | AC | 38 ms
24,040 KB |
testcase_06 | AC | 39 ms
23,720 KB |
testcase_07 | AC | 40 ms
23,972 KB |
testcase_08 | AC | 41 ms
24,168 KB |
testcase_09 | AC | 40 ms
24,096 KB |
testcase_10 | AC | 41 ms
24,268 KB |
testcase_11 | AC | 41 ms
24,300 KB |
testcase_12 | AC | 41 ms
23,664 KB |
testcase_13 | AC | 41 ms
24,288 KB |
testcase_14 | AC | 41 ms
24,488 KB |
testcase_15 | AC | 41 ms
24,116 KB |
testcase_16 | AC | 41 ms
24,272 KB |
testcase_17 | AC | 42 ms
24,124 KB |
testcase_18 | AC | 41 ms
24,264 KB |
testcase_19 | AC | 40 ms
24,468 KB |
testcase_20 | AC | 40 ms
24,000 KB |
testcase_21 | AC | 42 ms
23,640 KB |
testcase_22 | AC | 41 ms
23,424 KB |
testcase_23 | AC | 42 ms
23,556 KB |
testcase_24 | AC | 42 ms
23,592 KB |
testcase_25 | AC | 40 ms
23,536 KB |
ソースコード
import sys input = sys.stdin.readline N=int(input()) print("?",1,flush=True) x=int(input()) init=x print("?",N-1,flush=True) y=int(input()) if x==1 and y==N//2: print("!",2,N-1,flush=True) exit() elif x==0 and y==N//2-1: print("!",2,N-1,flush=True) exit() # 1~xの表 - 裏の枚数が0になるものを探す MIN=2 MAX=N-1 while True: mid=(MIN+MAX)//2 print("?",mid,flush=True) x=int(input()) y=mid-x if init==1: if x<y: MAX=mid elif x>y: MIN=mid else: break else: if x>y: MAX=mid elif x<y: MIN=mid else: break if mid>=N//2: print("!",1,mid,flush=True) else: print("!",mid+1,N,flush=True)