結果

問題 No.702 中央値を求めよ LIMITED
ユーザー 👑 obakyanobakyan
提出日時 2019-04-29 17:17:42
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 70,668 KB
実行使用メモリ 7,596 KB
最終ジャッジ日時 2023-08-26 02:35:13
合計ジャッジ時間 10,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,744 ms
4,380 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 #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#define L64 long long
#define MOD (1000000007LL)

uint32_t x = 0, y = 1, z = 2, w = 3;
int64_t g_seed;
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 check(uint32_t a, bool& same){
  same = false;
  uint32_t q;
  int ret = 0;
  x = g_seed;
  y = 1;
  z = 2;
  w = 3;
  for (int i = 0; i < 10000001; i++){
    q = generate();
    if(q < a){
      ret++;
    } else if(q == a){ same = true; }
  }
  return ret;
}

int main(void)
{
  bool same = false;
  std::cin >> g_seed;
  uint32_t min, max;
  min = 0; max = 4294967295;
  while(min != max){
    uint32_t mid = (min + max) / 2;
    int lownum = check(mid, same);
    if(lownum < 5000000){
      min = mid + 1;
    } else if(lownum == 5000000){
      if(same){
        std::cout << mid << std::endl;
        break;
      } else {
        min = mid + 1;
      }
    } else {
      max = mid;
    }
  }
}
0