結果

問題 No.513 宝探し2
ユーザー ei1333333ei1333333
提出日時 2017-05-05 22:33:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 144,104 KB
実行使用メモリ 24,312 KB
平均クエリ数 66.83
最終ジャッジ日時 2023-09-24 01:02:45
合計ジャッジ時間 2,378 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,952 KB
testcase_01 AC 27 ms
24,312 KB
testcase_02 AC 27 ms
23,520 KB
testcase_03 AC 28 ms
23,724 KB
testcase_04 AC 27 ms
23,736 KB
testcase_05 AC 26 ms
24,300 KB
testcase_06 AC 28 ms
23,784 KB
testcase_07 AC 27 ms
24,024 KB
testcase_08 AC 25 ms
23,604 KB
testcase_09 AC 26 ms
23,364 KB
testcase_10 AC 27 ms
23,328 KB
testcase_11 AC 27 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

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 << 0 << " " << mid << 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