結果

問題 No.253 ロウソクの長さ
ユーザー goodbatongoodbaton
提出日時 2015-07-24 22:44:54
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,031 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 71,444 KB
実行使用メモリ 34,520 KB
平均クエリ数 2.58
最終ジャッジ日時 2023-09-07 22:45:25
合計ジャッジ時間 4,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,952 KB
testcase_01 AC 24 ms
23,616 KB
testcase_02 AC 24 ms
24,024 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100

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

void ans(int Y){
    cout << "! " << Y << endl;
    return;
}

int main(){
    int res;
    
    int l=10,r=1000000000,mid;
    
    if(ask(31)==-1){
        
        for(int i=0;;i++){
            if(ask(0)==0){
                ans(i);
            }
        }
        
    }
    
    for(int i=1;i<=30;i++){
        
        mid = (l+r)/2;
        
        int q = ask(mid-i);
        
        if(q==1){
            l = mid+1;
        }else if(q==-1){
            r = mid;
        }else{
            ans(mid);
            return 0;
        }
        
    }
    
    return 0;
}
0