結果

問題 No.253 ロウソクの長さ
ユーザー koprickykopricky
提出日時 2017-08-15 02:23:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 2,060 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 144,700 KB
実行使用メモリ 24,288 KB
平均クエリ数 21.94
最終ジャッジ日時 2023-09-24 01:30:08
合計ジャッジ時間 4,116 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,988 KB
testcase_01 AC 25 ms
23,364 KB
testcase_02 AC 25 ms
23,928 KB
testcase_03 AC 25 ms
23,952 KB
testcase_04 AC 25 ms
23,772 KB
testcase_05 AC 25 ms
24,168 KB
testcase_06 AC 25 ms
23,364 KB
testcase_07 AC 26 ms
23,964 KB
testcase_08 AC 25 ms
23,952 KB
testcase_09 AC 25 ms
23,364 KB
testcase_10 AC 26 ms
23,472 KB
testcase_11 AC 26 ms
23,460 KB
testcase_12 AC 25 ms
23,628 KB
testcase_13 AC 25 ms
23,364 KB
testcase_14 AC 25 ms
23,460 KB
testcase_15 AC 25 ms
23,952 KB
testcase_16 AC 25 ms
23,748 KB
testcase_17 AC 25 ms
23,388 KB
testcase_18 AC 26 ms
24,264 KB
testcase_19 AC 25 ms
24,180 KB
testcase_20 AC 29 ms
24,288 KB
testcase_21 AC 25 ms
24,120 KB
testcase_22 AC 25 ms
23,736 KB
testcase_23 AC 26 ms
23,628 KB
testcase_24 AC 24 ms
23,988 KB
testcase_25 AC 26 ms
23,316 KB
testcase_26 AC 26 ms
23,304 KB
testcase_27 AC 26 ms
23,784 KB
testcase_28 AC 25 ms
23,400 KB
testcase_29 AC 25 ms
24,252 KB
testcase_30 AC 27 ms
23,292 KB
testcase_31 AC 26 ms
23,364 KB
testcase_32 AC 26 ms
23,976 KB
testcase_33 AC 26 ms
23,472 KB
testcase_34 AC 25 ms
23,388 KB
testcase_35 AC 26 ms
24,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l=10,h=1000000001;
    cout << "? " << 1000 << endl;
    int cnt = 0;
    int fres;
    cin >> fres;
    if(fres == 0){
        cout << "! " << fres << endl;
    }else if(fres < 0){
        h=1000;
        while(1){
            cnt++;
            l--,h--;
            int mid = (l+h)/2;
            if(mid == l){
                cout << "! " << mid + cnt << endl;
                return 0;
            }
            cout << "? " << mid << endl;
            int res;
            cin >> res;
            if(res == 0){
                cout << "! " << mid + cnt << endl;
                return 0;
            }else if(res < 0){
                h=mid;
            }else{
                l=mid+1;
            }
        }
    }else{
        l=1001;
        while(1){
            cnt++;
            l--,h--;
            int mid = (l+h)/2;
            if(mid == l){
                cout << "! " << mid + cnt << endl;
                return 0;
            }
            cout << "? " << mid << endl;
            int res;
            cin >> res;
            if(res == 0){
                cout << "! " << mid + cnt << endl;
                return 0;
            }else if(res < 0){
                h=mid;
            }else{
                l=mid+1;
            }
        }
    }
    return 0;
}
0