結果
| 問題 | No.253 ロウソクの長さ | 
| コンテスト | |
| ユーザー |  37kt_ | 
| 提出日時 | 2015-10-17 22:19:52 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 490 bytes | 
| コンパイル時間 | 1,257 ms | 
| コンパイル使用メモリ | 159,120 KB | 
| 実行使用メモリ | 39,856 KB | 
| 最終ジャッジ日時 | 2024-07-16 06:31:11 | 
| 合計ジャッジ時間 | 7,640 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 -- * 35 | 
コンパイルメッセージ
main.cpp: In function ‘int solve()’:
main.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
int ask(int x)
{
	static int cnt = 0;
	int res;
	assert(x - cnt >= 0);
	cout << "? " << x - cnt << endl;
	cin >> res;
	cnt++;
	return res;
}
int solve()
{
	if (ask(40) == -1){
		for (int i = 10;; i++){
			if (ask(i) == 0) return i;
		}
	}
	
	int l = 0, r = 1e9 + 10;
	while (l + 1 < r){
		int m = (l + r) / 2;
		int q = ask(m);
		if (q == 0) return m;
		if (q == -1) r = m;
		else l = m;
	}
}
int main()
{
	cout << "! " << solve() << endl;
}
            
            
            
        