結果

問題 No.253 ロウソクの長さ
ユーザー machymachy
提出日時 2015-07-25 00:16:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 51,804 KB
実行使用メモリ 24,516 KB
平均クエリ数 30.56
最終ジャッジ日時 2023-09-23 05:04:13
合計ジャッジ時間 6,120 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
    int left = 0;
    int right = 1000000001;
    int cnt = 0;
    int ans;
    cout << "? 100" << endl;
    cout.flush();
    cin >> ans;
    if(ans == -1){
        for(int i = 0; i < 99; i++){
            cout << "? 9" << endl;
            cout.flush();
            cin >> ans;
            if(ans == 0){
                cout << "! " << 10 + i << endl;
                break;
            }
        }
        return 0;
    }else if(ans == 0){
        cout << "! 100" << endl;
        return 0;
    }
    while(left + 1 < right){
        int middle = (left + right) / 2;
        cout << "? " << max(0, middle - cnt) << endl;
        cout.flush();
        int ans;
        cin >> ans;
        if(ans == -1){
            right = middle;
        }else if(ans == 0){
            left = middle;
            break;
        }else{
            left = middle+1;
        }
        cnt++;
    }
    cout << "! " << left << endl;
    return 0;
}
0