結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
|
提出日時 | 2022-06-10 06:12:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 854 ms / 5,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 1,805 ms |
コンパイル使用メモリ | 167,592 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 05:42:20 |
合計ジャッジ時間 | 25,136 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; 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(){ int64_t seed; int64_t ok = -1, ng = 1ll << 40 , mid, N = 10000001; cin >> seed; while(ok + 1 < ng){ mid = (ok + ng) / 2; x = seed, y = 1, z = 2, w = 3; uint32_t cnt = 0; for(uint32_t i = 0; i < N; i++){ cnt += (mid >= generate()); } if(cnt < (N + 1) / 2)ok = mid; else ng = mid; } cout << ok + 1 << endl; }