結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-09-27 21:35:30
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 546 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 531 ms
コンパイル使用メモリ 86,080 KB
実行使用メモリ 28,976 KB
平均クエリ数 38.75
最終ジャッジ日時 2026-03-30 22:58:45
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;


int ask(int Y){
	cout << "? " << Y << endl;
	int res;
	cin >> res;
	return res;
}

int main(){

	int l = 0; int r = INF + 1;
	rep(i, 50){
		int mid = (l + r) / 2;
		int ret = ask(mid);
		if(ret == -1){//短い
			r = mid;
		}else if(ret == 1){//長い
			l = mid - 1;
		}else if(ret == 0){
			printf("! %d\n", mid + i);
			return 0;
		}
	}

	return 0;
}
0