結果

問題 No.253 ロウソクの長さ
ユーザー beetbeet
提出日時 2018-12-05 16:01:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 198,248 KB
実行使用メモリ 24,396 KB
平均クエリ数 26.42
最終ジャッジ日時 2023-09-24 02:01:35
合計ジャッジ時間 5,215 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
24,072 KB
testcase_01 AC 26 ms
23,796 KB
testcase_02 AC 25 ms
23,400 KB
testcase_03 AC 25 ms
23,640 KB
testcase_04 AC 25 ms
24,240 KB
testcase_05 AC 25 ms
23,388 KB
testcase_06 AC 26 ms
23,508 KB
testcase_07 AC 26 ms
23,640 KB
testcase_08 AC 26 ms
24,396 KB
testcase_09 AC 25 ms
24,000 KB
testcase_10 AC 26 ms
23,436 KB
testcase_11 AC 25 ms
23,988 KB
testcase_12 AC 26 ms
23,676 KB
testcase_13 AC 26 ms
24,132 KB
testcase_14 AC 24 ms
23,556 KB
testcase_15 AC 25 ms
23,556 KB
testcase_16 AC 26 ms
24,072 KB
testcase_17 AC 26 ms
24,024 KB
testcase_18 AC 26 ms
23,640 KB
testcase_19 AC 25 ms
23,556 KB
testcase_20 AC 27 ms
23,400 KB
testcase_21 AC 25 ms
23,628 KB
testcase_22 AC 25 ms
24,024 KB
testcase_23 AC 25 ms
23,376 KB
testcase_24 AC 25 ms
24,000 KB
testcase_25 AC 25 ms
23,520 KB
testcase_26 AC 26 ms
23,436 KB
testcase_27 AC 26 ms
24,264 KB
testcase_28 AC 26 ms
23,676 KB
testcase_29 AC 26 ms
24,012 KB
testcase_30 AC 25 ms
23,400 KB
testcase_31 AC 25 ms
24,084 KB
testcase_32 AC 25 ms
23,664 KB
testcase_33 AC 25 ms
23,628 KB
testcase_34 AC 24 ms
23,352 KB
testcase_35 AC 25 ms
24,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int ask(Int x){
  cout<<"? "<<x<<endl;
  Int res;
  cin>>res;
  return res;
}
Int ans(Int x){
  cout<<"! "<<x<<endl;
  exit(0);
}

signed main(){
  Int l=10,r=1e9+100;
  
  Int x=ask(50);
  if(x==0) ans(50);

  if(x<0){
    for(Int i=0;i<50;i++){
      Int y=ask(10);
      if(y<0) ans(10+i);    
    }
  }else{
    Int t=1;
    for(Int i=0;i<40;i++){
      Int m=(l+r)>>1;
      Int y=ask(m-t++);
      if(y==0) ans(m);
      if(y>0) l=m;
      if(y<0) r=m;
    }
  }
  ans(l);
  return 0;
}
0