結果

問題 No.253 ロウソクの長さ
ユーザー koba-e964koba-e964
提出日時 2021-08-17 14:35:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,106 bytes
コンパイル時間 1,249 ms
コンパイル使用メモリ 117,204 KB
実行使用メモリ 25,476 KB
平均クエリ数 25.83
最終ジャッジ日時 2024-04-18 18:00:56
合計ジャッジ時間 5,908 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 21 ms
24,836 KB
testcase_02 AC 20 ms
24,964 KB
testcase_03 AC 19 ms
24,836 KB
testcase_04 AC 19 ms
24,580 KB
testcase_05 AC 21 ms
25,220 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 21 ms
24,580 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 23 ms
25,208 KB
testcase_15 AC 22 ms
25,220 KB
testcase_16 AC 20 ms
24,580 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 19 ms
24,964 KB
testcase_20 WA -
testcase_21 AC 18 ms
24,440 KB
testcase_22 AC 19 ms
25,208 KB
testcase_23 WA -
testcase_24 AC 26 ms
24,836 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 20 ms
24,964 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

ll query(ll lo, ll hi, int &nq) {
  while (hi - lo >= 2) {
    ll mid = (hi + lo) / 2;
    cout << "? " << mid - nq << endl;
    int res;
    cin >> res;
    nq++;
    if (res == 0) {
      return mid;
    }
    if (res > 0) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}

int main(void){
  cin.sync_with_stdio(false);
  int nq = 0;
  ll res = query(10, 100, nq);
  if (res <= 98) {
    cout << "! " << res << endl;
    return 0;
  }
  cout << "! " << query(98, 1e9 + 1, nq) << endl;
}
0