結果

問題 No.253 ロウソクの長さ
ユーザー kk
提出日時 2021-04-18 03:17:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 2,454 ms
コンパイル使用メモリ 197,112 KB
実行使用メモリ 24,480 KB
平均クエリ数 32.19
最終ジャッジ日時 2023-09-24 02:56:50
合計ジャッジ時間 5,045 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,724 KB
testcase_01 AC 25 ms
23,460 KB
testcase_02 AC 26 ms
24,288 KB
testcase_03 AC 26 ms
23,724 KB
testcase_04 AC 25 ms
23,688 KB
testcase_05 AC 27 ms
24,396 KB
testcase_06 AC 25 ms
24,084 KB
testcase_07 AC 26 ms
23,580 KB
testcase_08 AC 27 ms
24,384 KB
testcase_09 AC 25 ms
24,480 KB
testcase_10 AC 26 ms
23,904 KB
testcase_11 AC 25 ms
23,724 KB
testcase_12 AC 26 ms
23,724 KB
testcase_13 AC 26 ms
23,736 KB
testcase_14 AC 26 ms
24,348 KB
testcase_15 AC 26 ms
24,084 KB
testcase_16 AC 26 ms
23,436 KB
testcase_17 AC 26 ms
23,712 KB
testcase_18 AC 26 ms
24,072 KB
testcase_19 AC 25 ms
23,460 KB
testcase_20 AC 26 ms
24,072 KB
testcase_21 AC 27 ms
23,736 KB
testcase_22 AC 26 ms
23,712 KB
testcase_23 AC 25 ms
23,616 KB
testcase_24 AC 25 ms
24,108 KB
testcase_25 AC 26 ms
23,892 KB
testcase_26 AC 25 ms
23,436 KB
testcase_27 AC 26 ms
23,724 KB
testcase_28 AC 26 ms
24,372 KB
testcase_29 AC 25 ms
23,484 KB
testcase_30 AC 26 ms
23,472 KB
testcase_31 AC 27 ms
24,072 KB
testcase_32 AC 26 ms
23,736 KB
testcase_33 AC 26 ms
23,712 KB
testcase_34 AC 26 ms
23,436 KB
testcase_35 AC 25 ms
23,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int query(int y) {
  cout << "? " << y << endl;
  cout.flush();
  int x;
  cin >> x;
  return x;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  long long hi = numeric_limits<int>::max();
  long long lo = -1;

  int c = query(64);
  int t = 1;
  if (c <= 0) {
    for (;;) {
      c = query(0);
      if (c == 0) {
        cout << "! " << t << endl;
        return 0;
      }
      ++t;
    }
  } 

  while (hi - lo > 1) {
    long long mi = (lo + hi) / 2;
    c = query(mi - t);
    if (c > 0) lo = mi;
    else hi = mi;
    ++t;
  }
  
  cout << "! " << hi << endl;
  cout.flush();
  
  return 0;
}
0