結果

問題 No.513 宝探し2
ユーザー ei1333333ei1333333
提出日時 2017-05-05 22:31:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 1,279 ms
コンパイル使用メモリ 143,824 KB
実行使用メモリ 24,492 KB
平均クエリ数 67.00
最終ジャッジ日時 2023-09-23 13:17:41
合計ジャッジ時間 4,535 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 25 ms
23,496 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int unimodalFunc(int mid)
{
  cout << mid << " " << 0 << endl;
  int Q;
  cin >> Q;
  return(Q);
}


int unimodalFunc2(int mid)
{
  cout << mid << " " << 0 << endl;
  int Q;
  cin >> Q;
  return(Q);
}


int findMaximal(int from, int to)
{
  for(; to - from > 1;) {
    int mid = (from + to) / 2;
    (unimodalFunc(mid) - unimodalFunc(mid - 1) > 0 ? from : to) = mid;
  }
  return from;
}

int findMaximal2(int from, int to)
{
  for(; to - from > 1;) {
    int mid = (from + to) / 2;
    (unimodalFunc2(mid) - unimodalFunc2(mid - 1) > 0 ? from : to) = mid;
  }
  return from;
}

int main()
{
  int get = findMaximal(0, 100001);
  int get2 = findMaximal2(0, 100001);
  cout << get << " " << get2 << endl;
}
0