結果

問題 No.253 ロウソクの長さ
ユーザー latte0119latte0119
提出日時 2015-08-06 12:41:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 142,948 KB
実行使用メモリ 24,372 KB
平均クエリ数 22.08
最終ジャッジ日時 2023-09-23 21:19:54
合計ジャッジ時間 3,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,364 KB
testcase_01 AC 23 ms
23,364 KB
testcase_02 AC 25 ms
24,024 KB
testcase_03 AC 22 ms
23,436 KB
testcase_04 AC 24 ms
24,156 KB
testcase_05 AC 24 ms
24,096 KB
testcase_06 AC 26 ms
24,024 KB
testcase_07 AC 24 ms
24,120 KB
testcase_08 AC 26 ms
23,376 KB
testcase_09 AC 23 ms
23,904 KB
testcase_10 AC 23 ms
24,108 KB
testcase_11 AC 23 ms
23,460 KB
testcase_12 AC 24 ms
23,760 KB
testcase_13 AC 24 ms
23,628 KB
testcase_14 AC 22 ms
24,252 KB
testcase_15 AC 23 ms
24,228 KB
testcase_16 AC 23 ms
24,120 KB
testcase_17 AC 23 ms
23,664 KB
testcase_18 AC 25 ms
24,252 KB
testcase_19 AC 23 ms
23,520 KB
testcase_20 AC 24 ms
23,772 KB
testcase_21 AC 23 ms
24,132 KB
testcase_22 AC 24 ms
24,072 KB
testcase_23 AC 24 ms
23,388 KB
testcase_24 AC 23 ms
23,892 KB
testcase_25 AC 24 ms
24,048 KB
testcase_26 AC 24 ms
23,472 KB
testcase_27 AC 24 ms
24,036 KB
testcase_28 AC 26 ms
23,424 KB
testcase_29 AC 26 ms
24,372 KB
testcase_30 AC 23 ms
23,904 KB
testcase_31 AC 23 ms
23,388 KB
testcase_32 AC 23 ms
23,460 KB
testcase_33 AC 24 ms
24,036 KB
testcase_34 AC 22 ms
23,460 KB
testcase_35 AC 24 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int ask(int Y){
    printf("? %d\n",Y);
    fflush(stdout);
    int res;
    scanf("%d",&res);
    return res;
}

int main(){
    int ub,lb,cnt=1;
    if(ask(100)==-1){
        ub=100;
        lb=0;
    }
    else{
        ub=1e9;
        lb=0;
    }

    while(ub-lb>1){

        int mid=(ub+lb)/2;
        int r=ask(mid);
        if(r==1)lb=mid;
        else if(r==-1)ub=mid;
        else{
            printf("! %d\n",mid+cnt);
            fflush(stdout);
            return 0;
        }
        cnt++;
        ub--;
        lb--;
    }
    return 0;
}
0