結果

問題 No.253 ロウソクの長さ
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-27 21:35:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 65,232 KB
実行使用メモリ 24,408 KB
平均クエリ数 38.75
最終ジャッジ日時 2023-09-23 11:33:26
合計ジャッジ時間 6,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 26 ms
23,532 KB
testcase_04 WA -
testcase_05 AC 27 ms
24,060 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 27 ms
24,060 KB
testcase_09 WA -
testcase_10 AC 26 ms
23,832 KB
testcase_11 WA -
testcase_12 AC 25 ms
23,988 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 25 ms
23,388 KB
testcase_16 AC 26 ms
24,036 KB
testcase_17 WA -
testcase_18 AC 26 ms
23,532 KB
testcase_19 WA -
testcase_20 AC 26 ms
24,384 KB
testcase_21 AC 29 ms
24,264 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 26 ms
23,424 KB
testcase_26 WA -
testcase_27 AC 25 ms
23,520 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 26 ms
23,400 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 26 ms
23,376 KB
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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