結果
問題 |
No.2753 鳩の巣原理
|
ユーザー |
![]() |
提出日時 | 2024-05-10 23:50:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 70,644 KB |
平均クエリ数 | 11.00 |
最終ジャッジ日時 | 2024-12-20 08:02:02 |
合計ジャッジ時間 | 4,058 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
# 二分探索だな、2**10>1000, ABC299Dのようにできるか N = int(input()) low = 0 low_count = -10 high = N+1 high_count = N+10 ans = [0, 0] ans_flag = False for i in range(10): mid = (low+high)//2 print('?', mid) res = int(input()) if ans_flag == False: if res == low_count and mid != low: ans_flag = True ans = [mid-1, mid] elif res == high_count and mid != high: ans_flag = True ans = [mid, mid+1] if res < mid: high = mid high_count = res else: low = mid low_count = res #print('i', i, 'mid', mid, 'res', res, 'low', low, 'high', high, 'ans', ans, 'ans_flag', ans_flag) if ans == [0, 0]: print('No') else: print('Yes', *ans)