結果

問題 No.253 ロウソクの長さ
ユーザー pekempeypekempey
提出日時 2015-07-25 00:33:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,425 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 143,504 KB
実行使用メモリ 24,444 KB
平均クエリ数 34.97
最終ジャッジ日時 2023-09-23 21:01:10
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
23,412 KB
testcase_01 AC 24 ms
23,556 KB
testcase_02 AC 27 ms
24,384 KB
testcase_03 AC 25 ms
24,408 KB
testcase_04 AC 25 ms
24,396 KB
testcase_05 AC 27 ms
23,688 KB
testcase_06 AC 24 ms
24,444 KB
testcase_07 AC 24 ms
23,412 KB
testcase_08 AC 24 ms
23,460 KB
testcase_09 AC 23 ms
23,652 KB
testcase_10 AC 24 ms
23,868 KB
testcase_11 AC 26 ms
24,084 KB
testcase_12 AC 24 ms
24,060 KB
testcase_13 AC 25 ms
24,408 KB
testcase_14 AC 25 ms
23,688 KB
testcase_15 AC 27 ms
23,472 KB
testcase_16 AC 24 ms
23,448 KB
testcase_17 AC 24 ms
24,396 KB
testcase_18 AC 24 ms
23,412 KB
testcase_19 AC 25 ms
23,424 KB
testcase_20 AC 25 ms
23,700 KB
testcase_21 AC 26 ms
24,060 KB
testcase_22 AC 24 ms
23,568 KB
testcase_23 AC 25 ms
23,568 KB
testcase_24 AC 25 ms
23,424 KB
testcase_25 AC 25 ms
23,580 KB
testcase_26 AC 25 ms
24,060 KB
testcase_27 AC 25 ms
23,448 KB
testcase_28 AC 25 ms
23,436 KB
testcase_29 AC 25 ms
23,436 KB
testcase_30 AC 26 ms
24,360 KB
testcase_31 AC 24 ms
23,700 KB
testcase_32 AC 26 ms
23,568 KB
testcase_33 AC 24 ms
23,580 KB
testcase_34 AC 24 ms
24,060 KB
testcase_35 AC 25 ms
24,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define itall(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-8;
template<typename T> inline T sq(T a) { return a * a; }
template<typename T> inline T cb(T a) { return a * a * a; }
template<typename T> inline bool umin(T &a, const T &b) { return b < a && (a = b, true); }
template<typename T> inline bool umax(T &a, const T &b) { return a < b && (a = b, true); }

ll p10[10];

int query(int x) {
    cout << "? " << x << endl;
    int res;
    cin >> res;
    return res;
}

int main() {
    int ans = 0;

    if (query(99) < 0) {
        rep (i, 99) {
            if (query(0) == 0) {
                ans = 1 + i;
                break;
            }
        }
    } else {
        int l = 10, r = 1e9 + 1;
        for (int i = 0; r - l > 1 && i < 100; i++) {
            int m = (l + r) / 2;

            int q = query(m - i - 1);

            if (q == 0) {
                ans = m;
                break;
            } else if (q > 0) {
                l = m;
            } else {
                r = m;
            }
        }
    }

    cout << "! " << ans << endl;
}
0