結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー | xuzijian629 |
提出日時 | 2018-09-05 14:41:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 580 ms / 5,000 ms |
コード長 | 2,210 bytes |
コンパイル時間 | 1,315 ms |
コンパイル使用メモリ | 90,456 KB |
実行使用メモリ | 13,392 KB |
最終ジャッジ日時 | 2024-11-22 22:39:43 |
合計ジャッジ時間 | 17,753 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 573 ms
13,204 KB |
testcase_01 | AC | 546 ms
13,256 KB |
testcase_02 | AC | 563 ms
13,260 KB |
testcase_03 | AC | 580 ms
13,260 KB |
testcase_04 | AC | 549 ms
13,264 KB |
testcase_05 | AC | 543 ms
13,260 KB |
testcase_06 | AC | 546 ms
13,260 KB |
testcase_07 | AC | 550 ms
13,260 KB |
testcase_08 | AC | 546 ms
13,260 KB |
testcase_09 | AC | 547 ms
13,136 KB |
testcase_10 | AC | 540 ms
13,264 KB |
testcase_11 | AC | 567 ms
13,388 KB |
testcase_12 | AC | 551 ms
13,392 KB |
testcase_13 | AC | 547 ms
13,128 KB |
testcase_14 | AC | 546 ms
13,256 KB |
testcase_15 | AC | 547 ms
13,388 KB |
testcase_16 | AC | 544 ms
13,132 KB |
testcase_17 | AC | 550 ms
13,132 KB |
testcase_18 | AC | 543 ms
13,132 KB |
testcase_19 | AC | 554 ms
13,136 KB |
testcase_20 | AC | 545 ms
13,264 KB |
testcase_21 | AC | 558 ms
13,264 KB |
testcase_22 | AC | 555 ms
13,128 KB |
testcase_23 | AC | 571 ms
13,260 KB |
testcase_24 | AC | 543 ms
13,264 KB |
testcase_25 | AC | 563 ms
13,260 KB |
testcase_26 | AC | 556 ms
13,264 KB |
ソースコード
#include <iostream> #include <vector> #include <array> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <map> #include <unordered_map> #include <cassert> #pragma GCC optimize("O3") #pragma comment(linker, "STACK:36777216") using namespace std; using i64 = int64_t; constexpr i64 MOD = 1e9 + 7; using vi = vector<i64>; using vvi = vector<vi>; using vvvi = vector<vvi>; 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() { uint32_t seed; cin >> seed; x = seed; vector<uint32_t> tmp, reserved; int tmpsize = 1000001; for (int i = 0; i < tmpsize; i++) { tmp.push_back(generate()); } sort(tmp.begin(), tmp.end()); for (int i = 250000; i <= 750000; i++) { reserved.push_back(tmp[i]); } double off = 0; int small_cnt = 0; uint32_t min = reserved.front(), max = reserved.back(), mid = reserved[250000]; for (int i = 0; i < 9; i++) { assert(reserved.size() == 500001); for (int j = 0; j < 1000000; j++) { uint32_t u1 = generate(); if (u1 <= mid) { off -= 0.5; if (u1 > min) { small_cnt++; reserved.push_back(u1); } } if (u1 > mid) { off += 0.5; if (u1 < max) { reserved.push_back(u1); } } } sort(reserved.begin(), reserved.end()); assert(mid == reserved[250000 + small_cnt]); int new_mid_ind = 250000 + small_cnt + int(off); // cout << new_mid_ind << " " << reserved.size() << endl; tmp.clear(); for (int k = new_mid_ind - 250000; k <= new_mid_ind + 250000; k++) { assert(k >= 0 && k < reserved.size()); tmp.push_back(reserved[k]); } reserved = vector<uint32_t>(tmp); mid = reserved[250000]; min = reserved.front(); max = reserved.back(); off = 0; small_cnt = 0; } cout << mid << endl; }