結果

問題 No.253 ロウソクの長さ
ユーザー walkrewalkre
提出日時 2015-08-01 16:48:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,266 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 144,568 KB
実行使用メモリ 24,300 KB
平均クエリ数 29.28
最終ジャッジ日時 2023-09-23 21:15:42
合計ジャッジ時間 4,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,724 KB
testcase_01 AC 27 ms
24,096 KB
testcase_02 AC 26 ms
23,580 KB
testcase_03 AC 27 ms
23,460 KB
testcase_04 AC 26 ms
23,736 KB
testcase_05 AC 27 ms
23,460 KB
testcase_06 AC 26 ms
24,120 KB
testcase_07 AC 26 ms
23,856 KB
testcase_08 AC 26 ms
24,168 KB
testcase_09 AC 26 ms
24,156 KB
testcase_10 AC 26 ms
23,964 KB
testcase_11 AC 26 ms
24,156 KB
testcase_12 AC 26 ms
23,556 KB
testcase_13 AC 26 ms
23,556 KB
testcase_14 AC 25 ms
23,328 KB
testcase_15 AC 26 ms
24,084 KB
testcase_16 AC 26 ms
23,592 KB
testcase_17 AC 27 ms
23,448 KB
testcase_18 AC 26 ms
23,448 KB
testcase_19 AC 26 ms
23,580 KB
testcase_20 AC 26 ms
24,288 KB
testcase_21 AC 28 ms
23,964 KB
testcase_22 AC 28 ms
24,084 KB
testcase_23 AC 27 ms
24,180 KB
testcase_24 AC 26 ms
24,084 KB
testcase_25 AC 26 ms
23,448 KB
testcase_26 AC 27 ms
23,328 KB
testcase_27 AC 26 ms
23,568 KB
testcase_28 AC 26 ms
23,940 KB
testcase_29 AC 26 ms
23,448 KB
testcase_30 AC 26 ms
24,300 KB
testcase_31 AC 25 ms
23,868 KB
testcase_32 AC 26 ms
23,688 KB
testcase_33 AC 25 ms
23,328 KB
testcase_34 AC 26 ms
23,436 KB
testcase_35 AC 27 ms
24,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int LLNF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	{
		int res;
		cout << "? " << 50 << endl;
		cin >> res;
		if(res==-1){
			int k=1;
			while(true){
				cout << "? " << 0 << endl;
				cin >> res;
				if(res==0){
					cout << "! " << k << endl;
					return;
				}
				++k;
			}
		}
	}
	
	int lb=10,ub=1000000001,k=1;
	while(true){
		int mid=(lb+ub)/2,res;
		cout << "? " << mid << endl;
		cin >> res;
		if(res==0){
			cout << "! " << mid+k << endl;
			break;
		}else if(res==-1) ub=mid;
		else lb=mid;
		--lb;
		--ub;
		if(lb<0) lb=0;
		if(ub<0) ub=0;
		++k;
	}
}

int main(){
	Solve();
	return 0;
}
0