結果

問題 No.253 ロウソクの長さ
ユーザー furafura
提出日時 2020-06-11 01:24:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 197,412 KB
実行使用メモリ 24,420 KB
平均クエリ数 12.47
最終ジャッジ日時 2023-09-24 03:40:08
合計ジャッジ時間 7,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int ask(int x){
	printf("? %d\n",x);
	fflush(stdout);
	int res; scanf("%d",&res);
	return res;
}

void answer(int x){
	printf("! %d\n",x);
	fflush(stdout);
}

int main(){
	int res=ask(100);
	if(res==0){
		answer(100);
	}
	else if(res==-1){
		int t;
		for(t=1;ask(t)!=0;t++);
		answer(t);
	}
	else{
		int t=1;
		int lo=100,hi=1e9;
		while(hi-lo>1){
			int mi=(lo+hi)/2;
			if(ask(mi-t)!=-1) lo=mi;
			else              hi=mi;
			t++;
		}
		answer(lo);
	}

	return 0;
}
0