結果

問題 No.702 中央値を求めよ LIMITED
ユーザー sugdxsugdx
提出日時 2018-06-15 23:24:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 818 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 164,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 00:28:47
合計ジャッジ時間 36,892 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,889 ms
4,376 KB
testcase_01 AC 2,016 ms
4,380 KB
testcase_02 AC 2,023 ms
4,380 KB
testcase_03 AC 2,023 ms
4,376 KB
testcase_04 AC 1,965 ms
4,380 KB
testcase_05 AC 1,960 ms
4,384 KB
testcase_06 AC 2,020 ms
4,380 KB
testcase_07 AC 2,024 ms
4,376 KB
testcase_08 AC 2,014 ms
4,380 KB
testcase_09 AC 1,964 ms
4,380 KB
testcase_10 AC 2,032 ms
4,380 KB
testcase_11 AC 2,029 ms
4,380 KB
testcase_12 AC 1,900 ms
4,380 KB
testcase_13 TLE -
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 <bits/stdc++.h>
using namespace std;

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) {
    long long seed; cin >> seed;
    x = seed;
    long long left = 0; long long right = UINT32_MAX;
    for (int cas = 0; cas < 200; cas++) {
      long long mid = (left + right) / 2;
      int cnt = 0;
      for (int i = 0; i < 10000001; i++) {
        uint32_t  t = generate();
        if (t <= mid) cnt--;
        if (t >= mid) cnt++;
      }
      if (cnt == 0) {
        cout << mid << endl;
        return 0;
      }
      if (cnt > 0) left = mid+1;
      if (cnt < 0) right = mid;
      x = seed, y = 1, z = 2, w = 3;
    }
    cout << "NG" << endl;
    return 0;
}
0