結果

問題 No.702 中央値を求めよ LIMITED
ユーザー oshiborioshibori
提出日時 2018-06-16 02:18:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 675 ms / 5,000 ms
コード長 1,614 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 165,588 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-14 21:30:55
合計ジャッジ時間 21,320 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 644 ms
4,380 KB
testcase_01 AC 652 ms
4,380 KB
testcase_02 AC 647 ms
4,376 KB
testcase_03 AC 653 ms
4,380 KB
testcase_04 AC 661 ms
4,376 KB
testcase_05 AC 640 ms
4,380 KB
testcase_06 AC 657 ms
4,380 KB
testcase_07 AC 664 ms
4,380 KB
testcase_08 AC 662 ms
4,380 KB
testcase_09 AC 659 ms
4,376 KB
testcase_10 AC 662 ms
4,376 KB
testcase_11 AC 661 ms
4,384 KB
testcase_12 AC 663 ms
4,384 KB
testcase_13 AC 674 ms
4,376 KB
testcase_14 AC 675 ms
4,380 KB
testcase_15 AC 661 ms
4,376 KB
testcase_16 AC 663 ms
4,376 KB
testcase_17 AC 663 ms
4,376 KB
testcase_18 AC 666 ms
4,380 KB
testcase_19 AC 667 ms
4,380 KB
testcase_20 AC 663 ms
4,380 KB
testcase_21 AC 664 ms
4,376 KB
testcase_22 AC 665 ms
4,380 KB
testcase_23 AC 673 ms
4,380 KB
testcase_24 AC 671 ms
4,380 KB
testcase_25 AC 674 ms
4,388 KB
testcase_26 AC 672 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
uint32_t x, y, z, w;
uint64_t seed;
void init() {
  x = seed;
  y = 1, z = 2, w = 3;
}
int32_t generate() {
  uint32_t t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  return w;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  cin >> seed;
  init();
  dump(generate());
  dump(generate());
  dump(generate());
  dump(generate());
  dump(generate());
  dump(generate());
  int l = 0, r = (1ll << 32);
  int A = 10000001;
  while (abs(r - l) > 1) {
    int m = (l + r) / 2;
    init();
    int c = 0;
    loop(A) {
      int g = generate();
      if (g < 0)
        g += (1ll << 32);
      if (g < m)
        c++;
    }
    dump(l, r, m, c);

    if (c <= 5000000)
      l = m;
    else
      r = m;
  }
  cout << l << endl;

  return 0;
}
0