結果

問題 No.702 中央値を求めよ LIMITED
ユーザー どららどらら
提出日時 2018-06-15 23:03:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 623 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 164,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 21:10:34
合計ジャッジ時間 20,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 609 ms
4,376 KB
testcase_01 AC 611 ms
4,380 KB
testcase_02 AC 622 ms
4,376 KB
testcase_03 AC 615 ms
4,380 KB
testcase_04 AC 614 ms
4,380 KB
testcase_05 AC 607 ms
4,380 KB
testcase_06 AC 618 ms
4,376 KB
testcase_07 AC 623 ms
4,376 KB
testcase_08 AC 604 ms
4,380 KB
testcase_09 AC 608 ms
4,384 KB
testcase_10 AC 606 ms
4,376 KB
testcase_11 AC 602 ms
4,380 KB
testcase_12 AC 604 ms
4,380 KB
testcase_13 AC 613 ms
4,384 KB
testcase_14 AC 607 ms
4,380 KB
testcase_15 AC 606 ms
4,376 KB
testcase_16 AC 610 ms
4,376 KB
testcase_17 AC 609 ms
4,376 KB
testcase_18 AC 611 ms
4,380 KB
testcase_19 AC 610 ms
4,376 KB
testcase_20 AC 611 ms
4,380 KB
testcase_21 AC 599 ms
4,384 KB
testcase_22 AC 596 ms
4,380 KB
testcase_23 AC 601 ms
4,380 KB
testcase_24 AC 595 ms
4,380 KB
testcase_25 AC 586 ms
4,384 KB
testcase_26 AC 606 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

uint32_t x = 0, y = 1, z = 2, w = 3;
uint32_t generate() { 
  uint32_t t = (x^(x<<11));
  x = y;
  y = z;
  z = w;
  w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
  return w;
}

int main(void) {
  ll seed; cin >> seed; 

  int N = 10000001;

  ll lb = 0, ub = (ll)(UINT32_MAX) + 1;
  while(ub-lb>1){
    ll m = (lb+ub)/2;
    int n = 0;

    x = seed;
    y = 1;
    z = 2;
    w = 3;
    for (int i = 0; i < N; i++) {
      uint32_t g = generate();
      if(g <= m) n++;
    }

    if(n <= N/2) lb = m;
    else ub = m;
  }

  cout << ub << endl;

  return 0;
}
0