結果

問題 No.253 ロウソクの長さ
ユーザー outlineoutline
提出日時 2021-03-15 15:27:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,869 bytes
コンパイル時間 1,200 ms
コンパイル使用メモリ 132,668 KB
実行使用メモリ 24,504 KB
平均クエリ数 24.06
最終ジャッジ日時 2023-09-24 10:09:20
合計ジャッジ時間 6,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,388 KB
testcase_01 AC 24 ms
23,412 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 25 ms
23,364 KB
testcase_06 WA -
testcase_07 AC 26 ms
23,364 KB
testcase_08 AC 26 ms
24,312 KB
testcase_09 WA -
testcase_10 AC 26 ms
24,000 KB
testcase_11 AC 26 ms
23,424 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 25 ms
23,676 KB
testcase_15 AC 26 ms
23,652 KB
testcase_16 AC 25 ms
23,640 KB
testcase_17 AC 25 ms
23,412 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 25 ms
24,336 KB
testcase_22 AC 25 ms
23,544 KB
testcase_23 AC 27 ms
23,364 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 26 ms
23,544 KB
testcase_27 AC 26 ms
24,420 KB
testcase_28 WA -
testcase_29 AC 26 ms
24,024 KB
testcase_30 AC 26 ms
23,628 KB
testcase_31 AC 26 ms
23,436 KB
testcase_32 AC 27 ms
23,388 KB
testcase_33 AC 27 ms
23,376 KB
testcase_34 WA -
testcase_35 AC 26 ms
23,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // int ans;
    // cin >> ans;
    int lb = 10, ub = 100, t = 0, x;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        cout << "? " << mid << endl;
        // cout << "ans:" << ans-- << endl;
        cin >> x;
        if(x == 0){
            cout << "! " << mid + t << endl;
            return 0;
        }
        if(x == 1)  lb = mid;
        else    ub = mid;
        ++t;
    }
    if(ub < 100){
        cout << "! " << lb + t - 1 << endl;
        return 0;
    }
    lb = 100, ub = 1000000001;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        cout << "? " << mid << endl;
        // cout << "ans:" << ans-- << endl;
        cin >> x;
        if(x == 0){
            cout << "! " << mid + t << endl;
            return 0;
        }
        if(x == 1)  lb = mid;
        else    ub = mid;
        ++t;
    }
    cout << "! " << lb + t - 1 << endl;

    return 0;
}
0