結果

問題 No.253 ロウソクの長さ
ユーザー koyoprokoyopro
提出日時 2015-10-07 18:52:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 1,217 ms
コンパイル使用メモリ 144,088 KB
実行使用メモリ 24,444 KB
平均クエリ数 28.14
最終ジャッジ日時 2023-09-23 06:34:05
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,688 KB
testcase_01 AC 26 ms
24,312 KB
testcase_02 AC 27 ms
23,328 KB
testcase_03 AC 27 ms
23,460 KB
testcase_04 AC 27 ms
24,288 KB
testcase_05 AC 27 ms
23,436 KB
testcase_06 AC 27 ms
24,444 KB
testcase_07 AC 28 ms
23,412 KB
testcase_08 AC 28 ms
24,300 KB
testcase_09 AC 27 ms
23,712 KB
testcase_10 AC 28 ms
23,568 KB
testcase_11 AC 28 ms
23,676 KB
testcase_12 AC 27 ms
23,304 KB
testcase_13 AC 27 ms
23,340 KB
testcase_14 AC 26 ms
23,664 KB
testcase_15 AC 27 ms
23,952 KB
testcase_16 AC 27 ms
23,832 KB
testcase_17 AC 27 ms
23,424 KB
testcase_18 AC 28 ms
23,568 KB
testcase_19 AC 27 ms
23,412 KB
testcase_20 AC 28 ms
23,688 KB
testcase_21 AC 27 ms
24,216 KB
testcase_22 AC 26 ms
23,580 KB
testcase_23 AC 27 ms
23,568 KB
testcase_24 AC 27 ms
23,424 KB
testcase_25 AC 27 ms
23,676 KB
testcase_26 AC 27 ms
23,832 KB
testcase_27 AC 27 ms
23,664 KB
testcase_28 AC 26 ms
23,688 KB
testcase_29 AC 28 ms
23,436 KB
testcase_30 AC 27 ms
23,964 KB
testcase_31 AC 27 ms
23,340 KB
testcase_32 AC 28 ms
23,688 KB
testcase_33 AC 28 ms
23,568 KB
testcase_34 WA -
testcase_35 AC 28 ms
23,460 KB
権限があれば一括ダウンロードができます

ソースコード

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 (cnt % 10 == 0) {
            int ret10 = ask(20);
            if (ret10 == 0) {
                cout << "! " << 20 + cnt - 1 << endl;
                return 0;
            }
            if (ret10 == -1) {
                high = 20;
            }
        }
        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