結果

問題 No.253 ロウソクの長さ
ユーザー koyoprokoyopro
提出日時 2015-10-07 18:55:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 143,964 KB
実行使用メモリ 24,312 KB
平均クエリ数 27.83
最終ジャッジ日時 2023-09-23 21:50:29
合計ジャッジ時間 4,666 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
23,436 KB
testcase_01 AC 31 ms
23,316 KB
testcase_02 AC 29 ms
23,556 KB
testcase_03 AC 29 ms
23,544 KB
testcase_04 AC 27 ms
24,300 KB
testcase_05 AC 27 ms
24,264 KB
testcase_06 AC 28 ms
23,724 KB
testcase_07 AC 27 ms
23,280 KB
testcase_08 AC 27 ms
23,652 KB
testcase_09 AC 26 ms
23,844 KB
testcase_10 AC 28 ms
23,424 KB
testcase_11 AC 27 ms
24,240 KB
testcase_12 AC 27 ms
23,376 KB
testcase_13 AC 27 ms
23,424 KB
testcase_14 AC 26 ms
24,012 KB
testcase_15 AC 28 ms
24,300 KB
testcase_16 AC 26 ms
24,276 KB
testcase_17 AC 27 ms
23,952 KB
testcase_18 AC 27 ms
23,436 KB
testcase_19 AC 26 ms
23,736 KB
testcase_20 AC 27 ms
23,436 KB
testcase_21 AC 27 ms
23,316 KB
testcase_22 AC 26 ms
24,312 KB
testcase_23 AC 27 ms
23,940 KB
testcase_24 AC 27 ms
23,928 KB
testcase_25 AC 27 ms
23,940 KB
testcase_26 AC 27 ms
23,640 KB
testcase_27 AC 27 ms
23,664 KB
testcase_28 AC 27 ms
23,400 KB
testcase_29 AC 28 ms
23,400 KB
testcase_30 AC 28 ms
23,556 KB
testcase_31 AC 27 ms
24,252 KB
testcase_32 AC 27 ms
23,424 KB
testcase_33 AC 27 ms
24,000 KB
testcase_34 AC 26 ms
24,312 KB
testcase_35 AC 27 ms
23,328 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;
    int c10 = 20;
    REP(i,100) {
        if (cnt % 10 == 0) {
            int ret10 = ask(c10);
            if (ret10 == 0) {
                cout << "! " << c10 + cnt - 1 << endl;
                return 0;
            }
            if (ret10 == -1) {
                high = c10;
                low = 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