結果

問題 No.253 ロウソクの長さ
ユーザー 158b158b
提出日時 2015-07-24 23:52:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,209 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 24,420 KB
平均クエリ数 21.64
最終ジャッジ日時 2023-09-23 21:00:30
合計ジャッジ時間 3,591 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,036 KB
testcase_01 AC 24 ms
23,640 KB
testcase_02 AC 23 ms
24,264 KB
testcase_03 AC 25 ms
24,060 KB
testcase_04 AC 26 ms
24,300 KB
testcase_05 AC 26 ms
23,448 KB
testcase_06 AC 26 ms
24,060 KB
testcase_07 AC 26 ms
23,436 KB
testcase_08 AC 26 ms
24,312 KB
testcase_09 AC 25 ms
24,048 KB
testcase_10 AC 26 ms
24,072 KB
testcase_11 AC 27 ms
24,312 KB
testcase_12 AC 25 ms
23,472 KB
testcase_13 AC 26 ms
23,448 KB
testcase_14 AC 25 ms
24,108 KB
testcase_15 AC 24 ms
24,072 KB
testcase_16 AC 25 ms
23,664 KB
testcase_17 AC 25 ms
23,580 KB
testcase_18 AC 26 ms
23,712 KB
testcase_19 AC 25 ms
23,580 KB
testcase_20 AC 26 ms
23,652 KB
testcase_21 AC 25 ms
23,964 KB
testcase_22 AC 24 ms
23,580 KB
testcase_23 AC 25 ms
24,420 KB
testcase_24 AC 25 ms
24,036 KB
testcase_25 AC 25 ms
23,688 KB
testcase_26 AC 25 ms
24,312 KB
testcase_27 AC 26 ms
23,448 KB
testcase_28 AC 26 ms
23,676 KB
testcase_29 AC 26 ms
23,448 KB
testcase_30 AC 27 ms
24,276 KB
testcase_31 AC 25 ms
24,396 KB
testcase_32 AC 26 ms
23,844 KB
testcase_33 AC 27 ms
23,880 KB
testcase_34 AC 25 ms
24,396 KB
testcase_35 AC 26 ms
23,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:13: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘10000000001’ to ‘1410065409’ [-Woverflow]
  int maxd = 10000000001;
             ^~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
using namespace std;

//#define __int64 long long
//#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vecy[4] = {0,-1,0,1};
const int Vecx[4] = {1,0,-1,0};


int main(){
	int ans;
	int mind = 0;
	int maxd = 10000000001;
	int check;
	int result;
	
	int i = 0;
	cout << "? " << 100 << endl;
	cin >> result;
	if(result == 0){
		cout << "! 100" << endl;
		return 0;
	}
	
	if(result == -1){
		//100以下用
		mind = 0;
		maxd = 100;
		
		for(i=1; i<100; i++){
			check = (mind + maxd) / 2;
			cout << "? " << (check - i) << endl;
			cin >> result;
			if(result == 0){
				break;
			}
			if(result == -1){
				maxd = check;
			}else{
				mind = check;
			}
		}
		cout << "! " << check << endl;
	    return 0;
	}
	
	
	for(i=1; i<100; i++){
		check = (mind + maxd) / 2;
		cout << "? " << (check - i) << endl;
		cin >> result;
		if(result == 0){
			break;
		}
		if(result == -1){
			maxd = check;
		}else{
			mind = check;
		}
	}
	cout << "! " << check << endl;
	
    return 0;
}
0