結果

問題 No.253 ロウソクの長さ
ユーザー koyoprokoyopro
提出日時 2015-10-07 18:47:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 2,574 ms
コンパイル使用メモリ 143,732 KB
実行使用メモリ 24,456 KB
平均クエリ数 108.78
最終ジャッジ日時 2023-09-23 06:33:41
合計ジャッジ時間 7,138 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,568 KB
testcase_01 AC 27 ms
23,412 KB
testcase_02 AC 29 ms
23,448 KB
testcase_03 AC 26 ms
23,688 KB
testcase_04 AC 26 ms
23,688 KB
testcase_05 AC 27 ms
23,424 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 27 ms
23,820 KB
testcase_09 AC 25 ms
24,288 KB
testcase_10 WA -
testcase_11 AC 28 ms
23,976 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 25 ms
23,400 KB
testcase_15 AC 29 ms
23,844 KB
testcase_16 WA -
testcase_17 AC 27 ms
24,048 KB
testcase_18 AC 27 ms
24,036 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 26 ms
24,264 KB
testcase_22 AC 27 ms
24,288 KB
testcase_23 WA -
testcase_24 AC 28 ms
24,072 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 28 ms
23,688 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 27 ms
24,324 KB
testcase_34 AC 26 ms
24,204 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define REP(i, n) for(int i=0; i<(n); i++)

int cnt = 0;
int ask(int Y){
    cout << "? " << Y << endl;
    int res;
    cin >> res;
    cnt++;
    return res;
}
signed main()
{
    int high = (int)1e9;
    int low = 10;
    REP(i,100) {
        if (ask(10) == 0) {
            cout << "! " << 10 + cnt - 1 << endl;
            return 0;
        }
        int mid = (high + low) / 2;
        int ret = ask(mid);
        if (ret == 0) {
            cout << "! " << mid + cnt - 1 << endl;
            return 0;
        }
        if (ret == 1) {
            low = mid;
        } else {
            high = mid;
        }
        high = max(0, high-1);
        low = max(0, low-1);
    }
    return 0;
}
0