結果

問題 No.253 ロウソクの長さ
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-04 17:27:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 197,748 KB
実行使用メモリ 24,432 KB
平均クエリ数 33.86
最終ジャッジ日時 2023-09-24 02:57:11
合計ジャッジ時間 4,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,700 KB
testcase_01 AC 26 ms
23,892 KB
testcase_02 AC 27 ms
23,724 KB
testcase_03 AC 25 ms
23,604 KB
testcase_04 AC 24 ms
23,604 KB
testcase_05 AC 25 ms
23,484 KB
testcase_06 AC 25 ms
23,604 KB
testcase_07 AC 25 ms
24,108 KB
testcase_08 AC 25 ms
23,736 KB
testcase_09 AC 26 ms
23,892 KB
testcase_10 AC 26 ms
23,628 KB
testcase_11 AC 25 ms
24,312 KB
testcase_12 AC 24 ms
23,712 KB
testcase_13 AC 26 ms
23,700 KB
testcase_14 AC 24 ms
24,372 KB
testcase_15 AC 27 ms
24,420 KB
testcase_16 AC 25 ms
24,108 KB
testcase_17 AC 24 ms
24,072 KB
testcase_18 AC 25 ms
24,096 KB
testcase_19 AC 25 ms
23,736 KB
testcase_20 AC 25 ms
24,432 KB
testcase_21 AC 26 ms
24,360 KB
testcase_22 AC 26 ms
23,436 KB
testcase_23 AC 26 ms
23,604 KB
testcase_24 AC 27 ms
24,096 KB
testcase_25 AC 26 ms
24,108 KB
testcase_26 AC 26 ms
23,724 KB
testcase_27 AC 26 ms
23,724 KB
testcase_28 AC 25 ms
23,892 KB
testcase_29 AC 26 ms
23,472 KB
testcase_30 AC 26 ms
23,448 KB
testcase_31 AC 26 ms
24,348 KB
testcase_32 AC 26 ms
24,084 KB
testcase_33 AC 27 ms
24,408 KB
testcase_34 AC 26 ms
23,592 KB
testcase_35 AC 26 ms
23,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/253/
#include <bits/stdc++.h>
using namespace std;

int Time = -1;

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

int main() {
    int res = ask(100);
    if (res == 0)
        cout << "! 100" << endl;
    else if (res < 0) {
        while (res != 0)
            res = ask(1);
        cout << "! " << Time + 1 << endl;
    } else {
        int ok = 1e9 + 10;
        int ng = 0;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            res = ask(mid - Time);
            if (res == 0) {
                ok = mid;
                break;
            }
            if (res == -1) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << "! " << ok + 1 << endl;
    }
}
0