結果

問題 No.253 ロウソクの長さ
ユーザー kotatsugamekotatsugame
提出日時 2020-03-02 20:28:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 63,148 KB
実行使用メモリ 24,408 KB
平均クエリ数 31.31
最終ジャッジ日時 2023-09-24 02:31:34
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,388 KB
testcase_01 AC 24 ms
24,408 KB
testcase_02 AC 25 ms
24,324 KB
testcase_03 AC 23 ms
24,324 KB
testcase_04 AC 25 ms
24,048 KB
testcase_05 AC 25 ms
23,832 KB
testcase_06 AC 25 ms
23,376 KB
testcase_07 AC 25 ms
23,652 KB
testcase_08 AC 25 ms
23,376 KB
testcase_09 AC 26 ms
24,036 KB
testcase_10 AC 26 ms
24,204 KB
testcase_11 AC 25 ms
23,664 KB
testcase_12 AC 24 ms
23,556 KB
testcase_13 AC 25 ms
23,412 KB
testcase_14 AC 23 ms
24,012 KB
testcase_15 AC 27 ms
23,520 KB
testcase_16 AC 24 ms
24,012 KB
testcase_17 AC 24 ms
24,036 KB
testcase_18 AC 25 ms
23,556 KB
testcase_19 AC 23 ms
24,312 KB
testcase_20 AC 24 ms
24,324 KB
testcase_21 AC 25 ms
23,508 KB
testcase_22 AC 24 ms
23,544 KB
testcase_23 AC 24 ms
24,036 KB
testcase_24 AC 25 ms
24,384 KB
testcase_25 AC 25 ms
23,808 KB
testcase_26 AC 24 ms
24,036 KB
testcase_27 AC 25 ms
24,048 KB
testcase_28 AC 24 ms
24,336 KB
testcase_29 AC 23 ms
23,676 KB
testcase_30 AC 24 ms
23,508 KB
testcase_31 AC 23 ms
23,544 KB
testcase_32 AC 24 ms
24,408 KB
testcase_33 AC 25 ms
24,384 KB
testcase_34 AC 23 ms
23,652 KB
testcase_35 AC 24 ms
23,568 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int ask(int Y)
{
	cout<<"? "<<Y<<endl;
	int ret;
	cin>>ret;
	return ret;
}
main()
{
	int fst=ask(100);
	int ans;
	if(fst==0)
	{
		ans=100;
	}
	else if(fst<0)
	{
		int tm=1;
		for(;;)
		{
			if(ask(9)==0)break;
			tm++;
		}
		ans=tm+9;
	}
	else
	{
		int L=100,R=1e9+1;
		int tm=1;
		while(R-L>1)
		{
			int M=(L+R)/2;
			if(ask(M-tm)<0)R=M;
			else L=M;
			tm++;
		}
		ans=L;
	}
	cout<<"! "<<ans<<endl;
}
0