結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-10-17 21:51:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 510 bytes |
コンパイル時間 | 1,590 ms |
コンパイル使用メモリ | 166,360 KB |
実行使用メモリ | 40,012 KB |
平均クエリ数 | 18.56 |
最終ジャッジ日時 | 2024-07-16 06:29:28 |
合計ジャッジ時間 | 9,033 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 19 TLE * 1 -- * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int ask(int x) { static int cnt = 0; static map<int, int> cac; if (cac.count(x - cnt)) return cac[x - cnt]; int res; cout << "? " << x - cnt++ << endl; cin >> res; return res; } int solve() { if (ask(100) == 0) return 100; int l, r; if (ask(100) < 0) l = 0, r = 100; else l = 100, r = 1e9 + 10; while (true){ int m = (l + r) / 2; if (ask(m) == 0) return m; if (ask(m) == -1) r = m; else l = m; } } int main() { cout << solve() << endl; }