結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-12-31 19:10:59 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 591 bytes |
コンパイル時間 | 12,633 ms |
コンパイル使用メモリ | 381,896 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:48:44 |
合計ジャッジ時間 | 13,316 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
fn main() { let _ = read::<u32>(); let mut a = read_vec::<i32>(); a.sort(); let a:Vec<f64> = a.into_iter().map(|n|n as f64).collect(); if a.len() % 2 == 1 { println!("{}", a[a.len()/2]); } else { println!("{}", (a[a.len()/2]+a[a.len()/2-1])/2f64); } } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() }