結果

問題 No.275 中央値を求めよ
ユーザー bubo
提出日時 2018-03-03 19:03:07
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 468 bytes
コンパイル時間 12,776 ms
コンパイル使用メモリ 379,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 00:53:07
合計ジャッジ時間 13,504 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::stdin;
pub fn main() {
    let line = || {
        let mut buf = String::new();
        let _ = stdin().read_line(&mut buf);
        buf
    };
    let n: usize = line().trim().parse().unwrap();
    let mut v: Vec<i32> = line().split_whitespace().flat_map(|x| x.parse()).collect();
    v.sort();
    let answer: f64 = match n % 2 {
        0 => (v[n / 2 - 1] + v[n / 2]) as f64 / 2.0,
        _ => v[n / 2] as f64,
    };
    println!("{:.1}", answer);
}
0