結果
| 問題 | No.702 中央値を求めよ LIMITED |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-09-24 19:36:17 |
| 言語 | Rust (1.97.1 + proconio + num + itertools + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 438 ms / 5,000 ms |
| + 989µs | |
| コード長 | 1,342 bytes |
| 記録 | |
| コンパイル時間 | 11,819 ms |
| コンパイル使用メモリ | 192,308 KB |
| 実行使用メモリ | 9,916 KB |
| 最終ジャッジ日時 | 2026-09-24 19:36:45 |
| 合計ジャッジ時間 | 26,149 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::Chars, marker::Usize1};
use std::cmp::{Reverse, max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn generate(seed: u32) -> impl FnMut() -> u32 {
let mut x = seed;
let mut y = 1;
let mut z = 2;
let mut w = 3;
move || {
let t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
w
}
}
fn main() {
input! {
seed: u32,
}
const SIZE: usize = 10_000_001;
let k = SIZE / 2;
let mut lo: i64 = 0;
let mut hi: i64 = u32::MAX as i64;
let mut res = hi;
while lo <= hi {
let m = lo.midpoint(hi);
let cnt = std::iter::repeat_with(generate(seed))
.take(SIZE)
.filter(|&x| x as i64 <= m)
.count();
if cnt > k {
hi = m - 1;
res = res.min(m);
} else {
lo = m + 1;
}
}
println!("{}", res);
}
norioc