結果
問題 | No.253 ロウソクの長さ |
ユーザー | ciel |
提出日時 | 2015-07-24 23:36:26 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 25,532 KB |
実行使用メモリ | 24,336 KB |
平均クエリ数 | 29.81 |
最終ジャッジ日時 | 2023-09-23 05:01:37 |
合計ジャッジ時間 | 4,376 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
23,388 KB |
testcase_01 | AC | 26 ms
23,964 KB |
testcase_02 | AC | 26 ms
23,580 KB |
testcase_03 | AC | 26 ms
23,400 KB |
testcase_04 | WA | - |
testcase_05 | AC | 26 ms
23,676 KB |
testcase_06 | AC | 26 ms
23,412 KB |
testcase_07 | AC | 27 ms
24,336 KB |
testcase_08 | AC | 26 ms
23,424 KB |
testcase_09 | WA | - |
testcase_10 | AC | 26 ms
23,664 KB |
testcase_11 | AC | 27 ms
23,580 KB |
testcase_12 | AC | 27 ms
23,664 KB |
testcase_13 | AC | 28 ms
23,856 KB |
testcase_14 | WA | - |
testcase_15 | AC | 27 ms
23,844 KB |
testcase_16 | WA | - |
testcase_17 | AC | 26 ms
23,616 KB |
testcase_18 | AC | 26 ms
23,388 KB |
testcase_19 | WA | - |
testcase_20 | AC | 27 ms
23,436 KB |
testcase_21 | AC | 27 ms
23,544 KB |
testcase_22 | WA | - |
testcase_23 | AC | 26 ms
23,556 KB |
testcase_24 | AC | 26 ms
23,604 KB |
testcase_25 | AC | 25 ms
24,228 KB |
testcase_26 | AC | 26 ms
23,796 KB |
testcase_27 | AC | 26 ms
23,592 KB |
testcase_28 | AC | 27 ms
23,388 KB |
testcase_29 | AC | 27 ms
24,228 KB |
testcase_30 | AC | 27 ms
23,664 KB |
testcase_31 | AC | 26 ms
23,844 KB |
testcase_32 | AC | 26 ms
23,952 KB |
testcase_33 | AC | 26 ms
23,592 KB |
testcase_34 | AC | 26 ms
23,388 KB |
testcase_35 | AC | 26 ms
23,604 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; f=false; 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; })); }