結果
問題 | No.253 ロウソクの長さ |
ユーザー | ciel |
提出日時 | 2015-07-24 23:35:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 132 ms |
コンパイル使用メモリ | 25,664 KB |
実行使用メモリ | 24,468 KB |
平均クエリ数 | 29.72 |
最終ジャッジ日時 | 2023-09-23 05:01:02 |
合計ジャッジ時間 | 3,845 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,264 KB |
testcase_01 | AC | 26 ms
23,844 KB |
testcase_02 | AC | 25 ms
23,940 KB |
testcase_03 | AC | 24 ms
23,436 KB |
testcase_04 | WA | - |
testcase_05 | AC | 25 ms
23,628 KB |
testcase_06 | AC | 31 ms
23,400 KB |
testcase_07 | AC | 25 ms
24,192 KB |
testcase_08 | AC | 26 ms
23,424 KB |
testcase_09 | WA | - |
testcase_10 | AC | 25 ms
23,640 KB |
testcase_11 | AC | 26 ms
24,264 KB |
testcase_12 | AC | 25 ms
24,300 KB |
testcase_13 | AC | 25 ms
23,376 KB |
testcase_14 | WA | - |
testcase_15 | AC | 25 ms
23,952 KB |
testcase_16 | AC | 26 ms
23,844 KB |
testcase_17 | AC | 25 ms
23,388 KB |
testcase_18 | AC | 27 ms
23,676 KB |
testcase_19 | WA | - |
testcase_20 | AC | 25 ms
23,652 KB |
testcase_21 | AC | 24 ms
24,060 KB |
testcase_22 | WA | - |
testcase_23 | AC | 26 ms
23,844 KB |
testcase_24 | AC | 25 ms
23,388 KB |
testcase_25 | AC | 26 ms
24,312 KB |
testcase_26 | AC | 28 ms
23,388 KB |
testcase_27 | AC | 25 ms
23,616 KB |
testcase_28 | AC | 24 ms
23,940 KB |
testcase_29 | AC | 25 ms
23,832 KB |
testcase_30 | AC | 26 ms
24,072 KB |
testcase_31 | AC | 26 ms
23,640 KB |
testcase_32 | AC | 26 ms
23,388 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 26 ms
23,388 KB |
ソースコード
#include <cstdio> // cpp_binarysearch (C) @cielavenir under Boost Software License. // type F should be something like std::function<bool(T)>. template<typename T,typename F> T binarysearch(T lo,T hi,T eps,const F &checker){ int c=0; bool f=true; for(;lo+eps<hi;c++){ T mi=(lo+hi)/2; //if(f)mi=10; int z=checker(mi); if(z==0)return mi+c; if(z==1)lo=mi-1,hi=hi-1; if(z==-1)hi=mi-1,lo=lo-1; if(lo<0)lo=0; if(hi<0)hi=0; } return lo+c-1; } template<typename T,typename F> T binarysearch(T lo,T hi,const F &checker){return binarysearch(lo,hi,1,checker);} int main(){ printf("! %d\n",binarysearch(1,1000000000,[&](int t){ printf("? %d\n",t); fflush(stdout); int f; scanf("%d",&f); return f; })); }