結果

問題 No.253 ロウソクの長さ
ユーザー tanimani364tanimani364
提出日時 2019-12-05 17:36:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,513 bytes
コンパイル時間 1,220 ms
コンパイル使用メモリ 131,900 KB
実行使用メモリ 24,480 KB
平均クエリ数 54.36
最終ジャッジ日時 2023-09-24 02:22:14
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,844 KB
testcase_01 AC 25 ms
24,060 KB
testcase_02 AC 27 ms
23,556 KB
testcase_03 AC 26 ms
23,424 KB
testcase_04 AC 25 ms
23,640 KB
testcase_05 AC 25 ms
24,012 KB
testcase_06 AC 27 ms
24,048 KB
testcase_07 AC 27 ms
24,348 KB
testcase_08 AC 28 ms
24,000 KB
testcase_09 AC 25 ms
23,688 KB
testcase_10 AC 27 ms
23,544 KB
testcase_11 AC 27 ms
24,048 KB
testcase_12 AC 27 ms
23,688 KB
testcase_13 AC 26 ms
24,360 KB
testcase_14 AC 24 ms
23,700 KB
testcase_15 AC 26 ms
23,580 KB
testcase_16 AC 25 ms
23,544 KB
testcase_17 AC 25 ms
23,856 KB
testcase_18 AC 27 ms
24,384 KB
testcase_19 AC 25 ms
23,568 KB
testcase_20 AC 29 ms
23,844 KB
testcase_21 AC 26 ms
23,844 KB
testcase_22 AC 25 ms
24,432 KB
testcase_23 AC 27 ms
23,964 KB
testcase_24 AC 27 ms
23,424 KB
testcase_25 AC 28 ms
24,264 KB
testcase_26 AC 27 ms
24,480 KB
testcase_27 AC 28 ms
24,024 KB
testcase_28 AC 28 ms
23,856 KB
testcase_29 AC 27 ms
24,048 KB
testcase_30 AC 27 ms
23,640 KB
testcase_31 AC 27 ms
23,448 KB
testcase_32 AC 28 ms
24,048 KB
testcase_33 AC 28 ms
24,036 KB
testcase_34 AC 24 ms
23,436 KB
testcase_35 AC 27 ms
24,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

int C(int mid){
    cout<<"? "<<mid<<endl;
    int res;
    cin>>res;
    return res;
}
void solve(){
    int l,r,mid;
    int cnt=0;
    int x;
    rep(i,50){
        mid=i+10;
        x=C(mid);
        if(x==-1){
            cout<<"! "<<mid+cnt-1<<endl;
            return;
        }
        else if(x==0){
            cout<<"! "<<mid+cnt<<endl;
            return;
        }
        ++cnt;
    }
    l=109,r=1e9+1;
    rep(i,50){
        mid=(l+r)/2;
        x=C(mid-cnt);
        if(x==-1)r=mid;
        else if(x==1)l=mid;
        else {
            cout<<"! "<<mid<<endl;
            return ;
        }
        ++cnt;
    }
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}
0