結果

問題 No.253 ロウソクの長さ
ユーザー face4face4
提出日時 2018-11-15 13:11:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 64,108 KB
実行使用メモリ 24,264 KB
平均クエリ数 34.81
最終ジャッジ日時 2023-09-24 02:01:29
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,772 KB
testcase_01 AC 24 ms
23,748 KB
testcase_02 AC 26 ms
23,928 KB
testcase_03 AC 24 ms
23,388 KB
testcase_04 AC 24 ms
24,012 KB
testcase_05 AC 25 ms
24,000 KB
testcase_06 AC 24 ms
23,628 KB
testcase_07 AC 24 ms
23,628 KB
testcase_08 AC 23 ms
23,376 KB
testcase_09 AC 25 ms
23,916 KB
testcase_10 AC 23 ms
23,772 KB
testcase_11 AC 22 ms
23,916 KB
testcase_12 AC 21 ms
23,316 KB
testcase_13 AC 22 ms
23,688 KB
testcase_14 AC 21 ms
24,264 KB
testcase_15 AC 26 ms
24,012 KB
testcase_16 AC 22 ms
23,904 KB
testcase_17 AC 23 ms
23,352 KB
testcase_18 AC 22 ms
23,760 KB
testcase_19 AC 23 ms
23,328 KB
testcase_20 AC 21 ms
23,484 KB
testcase_21 AC 23 ms
24,012 KB
testcase_22 AC 23 ms
24,024 KB
testcase_23 AC 22 ms
23,520 KB
testcase_24 AC 24 ms
23,316 KB
testcase_25 AC 24 ms
23,628 KB
testcase_26 AC 23 ms
24,132 KB
testcase_27 AC 22 ms
24,144 KB
testcase_28 AC 22 ms
23,316 KB
testcase_29 AC 23 ms
24,000 KB
testcase_30 AC 22 ms
23,988 KB
testcase_31 AC 22 ms
23,616 KB
testcase_32 AC 23 ms
23,916 KB
testcase_33 AC 21 ms
23,208 KB
testcase_34 AC 21 ms
23,508 KB
testcase_35 AC 21 ms
23,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int ask(int Y){
	cout << "? " << Y << endl << flush;
	int res;
	cin >> res;
	return res;
}

void answer(int Y){
    cout << "! " << Y << endl << flush;
}

int main(){
    if(ask(99) <= 0){
        for(int i = 1;;i++){
            if(ask(0) == 0){
                answer(i);
                return 0;
            }
        }
    }

    // l inclusive, r inclusive
    int l = 10, r = 1000000000;
    int cnt = 1;

    while(r-l > 1){
        int mid = (l+r)/2;
        switch(ask(mid-cnt)){
            case -1:
                r = mid;
                break;
            case 1:
                l = mid+1;
                break;
            case 0:
                answer(mid);
                return 0;
        }
        cnt++;
    }

    answer(l);

    return 0;
}
0