結果

問題 No.253 ロウソクの長さ
ユーザー eve__fuyukieve__fuyuki
提出日時 2018-03-16 21:01:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 51,948 KB
実行使用メモリ 24,372 KB
平均クエリ数 21.33
最終ジャッジ日時 2023-09-24 01:43:04
合計ジャッジ時間 3,652 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,676 KB
testcase_01 AC 25 ms
24,216 KB
testcase_02 AC 24 ms
23,364 KB
testcase_03 AC 25 ms
23,412 KB
testcase_04 AC 27 ms
23,520 KB
testcase_05 AC 25 ms
23,988 KB
testcase_06 AC 26 ms
23,376 KB
testcase_07 AC 25 ms
23,616 KB
testcase_08 AC 26 ms
23,652 KB
testcase_09 AC 25 ms
23,376 KB
testcase_10 AC 25 ms
24,324 KB
testcase_11 AC 25 ms
23,796 KB
testcase_12 AC 25 ms
23,364 KB
testcase_13 AC 25 ms
23,640 KB
testcase_14 AC 24 ms
23,628 KB
testcase_15 AC 24 ms
23,988 KB
testcase_16 AC 26 ms
23,784 KB
testcase_17 AC 25 ms
24,012 KB
testcase_18 AC 26 ms
23,520 KB
testcase_19 AC 25 ms
23,376 KB
testcase_20 AC 26 ms
24,372 KB
testcase_21 AC 25 ms
23,412 KB
testcase_22 AC 25 ms
23,796 KB
testcase_23 AC 25 ms
23,520 KB
testcase_24 AC 24 ms
23,520 KB
testcase_25 AC 25 ms
23,376 KB
testcase_26 AC 25 ms
24,012 KB
testcase_27 AC 25 ms
23,616 KB
testcase_28 AC 26 ms
23,412 KB
testcase_29 AC 25 ms
23,796 KB
testcase_30 AC 25 ms
23,784 KB
testcase_31 AC 25 ms
23,388 KB
testcase_32 AC 25 ms
23,832 KB
testcase_33 AC 26 ms
23,520 KB
testcase_34 AC 24 ms
23,232 KB
testcase_35 AC 26 ms
24,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int timer = 0;
int ask(int Y){
	cout << "? " << Y << endl;
	int res;
    cin >> res;
    timer++;
	return res;
}
int main(){
    int res = ask(100);
    int min = 10;
    int max = 1e9;
    int mid;
    if(res == 0){
        cout << "! " << 100 << endl;
        return 0;
    }
    else if(res < 0) max = 99;
    else min = 101;
    while(1){
        mid = min + (max-min)/2;
        res = ask(mid - timer);
        if(res == 0){
            cout << "! " << mid << endl;
            break;
        }
        else if(res == 1){
            min = mid+1;
        }
        else{
            max = mid-1;
        }
    }
	return 0;
}
0