結果

問題 No.253 ロウソクの長さ
ユーザー tanimani364tanimani364
提出日時 2019-12-05 09:54:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 1,251 ms
コンパイル使用メモリ 130,440 KB
実行使用メモリ 24,420 KB
平均クエリ数 51.69
最終ジャッジ日時 2023-09-23 19:13:54
合計ジャッジ時間 5,277 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
23,856 KB
testcase_01 AC 25 ms
24,060 KB
testcase_02 AC 24 ms
23,652 KB
testcase_03 AC 24 ms
24,360 KB
testcase_04 AC 24 ms
23,856 KB
testcase_05 AC 25 ms
24,288 KB
testcase_06 AC 27 ms
24,408 KB
testcase_07 AC 26 ms
23,412 KB
testcase_08 AC 28 ms
24,360 KB
testcase_09 AC 25 ms
24,384 KB
testcase_10 AC 26 ms
23,652 KB
testcase_11 AC 26 ms
23,856 KB
testcase_12 AC 26 ms
23,688 KB
testcase_13 AC 27 ms
23,556 KB
testcase_14 AC 23 ms
24,048 KB
testcase_15 AC 24 ms
24,384 KB
testcase_16 AC 24 ms
7,852 KB
testcase_17 WA -
testcase_18 AC 27 ms
24,324 KB
testcase_19 AC 23 ms
24,024 KB
testcase_20 AC 27 ms
24,348 KB
testcase_21 AC 25 ms
23,400 KB
testcase_22 AC 24 ms
23,724 KB
testcase_23 AC 26 ms
24,024 KB
testcase_24 AC 24 ms
23,436 KB
testcase_25 AC 26 ms
24,324 KB
testcase_26 AC 26 ms
24,360 KB
testcase_27 AC 26 ms
24,060 KB
testcase_28 AC 27 ms
24,360 KB
testcase_29 AC 26 ms
24,408 KB
testcase_30 AC 27 ms
24,420 KB
testcase_31 AC 27 ms
24,372 KB
testcase_32 AC 26 ms
24,372 KB
testcase_33 WA -
testcase_34 AC 24 ms
23,844 KB
testcase_35 AC 24 ms
23,436 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=10,r=100;
    int cnt=0;
    int x,y=10;
    rep(i,50){
       int mid=(l+r)/2;
        if(mid-cnt>=0)x=C(mid-cnt);
        else break;
        if(x==-1)r=mid;
        else if(x==1)l=mid;
        else {
            cout<<"! "<<mid<<endl;
            return ;
        }
        ++cnt;
    }
    l=10,r=1e9;
    rep(i,50){
        int mid=(l+r)/2;
        if(mid-cnt>=0)x=C(mid-cnt);
        //else break;
        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