結果
問題 | No.253 ロウソクの長さ |
ユーザー | not_522 |
提出日時 | 2015-08-17 23:08:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 159,748 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 32.00 |
最終ジャッジ日時 | 2024-07-16 05:41:10 |
合計ジャッジ時間 | 7,815 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long binarySearch(function<bool(long long)> func, long long include, long long exclude) { while (abs(exclude - include) > 1) { long long middle = (include + exclude) / 2; (func(middle) ? include : exclude) = middle; } return include; } int main() { int cnt = 0; auto f = [&](int m){ cout << "? " << m - cnt << endl; ++cnt; int res; cin >> res; return res >= 0; }; cout << "! " << binarySearch(f, 10, f(100) ? 1e9 + 1 : 101) << endl; }