結果

問題 No.702 中央値を求めよ LIMITED
ユーザー tnakao0123tnakao0123
提出日時 2018-06-18 20:26:48
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,161 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 83,356 KB
実行使用メモリ 7,588 KB
最終ジャッジ日時 2023-09-13 06:55:35
合計ジャッジ時間 8,506 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 661 ms
4,384 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 702.cc: No.702 中央値を求めよ LIMITED - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 10000001;
const int MED = (N + 1) / 2;

const uint32_t UINF = ~0U;

/* typedef */

typedef uint32_t ui;

/* global variables */

ui x = 0, y = 1, z = 2, w = 3;

/* subroutines */

inline ui generate(ui &x, ui &y, ui &z, ui &w) {
  ui t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  return w;
}

/* main */

int main() {
  ui seed;
  scanf("%u", &seed);

  ui l = 0, r = UINF;
  while (l + 1 < r) {
    ui m = (l + r) / 2;

    int cnt = 0;
    ui x = seed, y = 1, z = 2, w = 3;
    for (int i = 0; i < N; i++) {
      ui ai = generate(x, y, z, w);
      if (ai <= m) cnt++;
    }

    if (cnt >= MED) r = m;
    else l = m;
  }

  printf("%u\n", r);
  return 0;
}
0