結果

問題 No.609 Noelちゃんと星々
ユーザー pekempey
提出日時 2017-12-09 01:06:37
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 13,305 ms
コンパイル使用メモリ 379,400 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-29 21:55:51
合計ジャッジ時間 15,036 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
  use std::io::prelude::*;
  let cin = std::io::stdin();
  let reader = std::io::BufReader::new(cin.lock());
  let mut lines = reader.lines();

  lines.next();
  let mut a: Vec<i64> = lines.next().unwrap().unwrap().split_whitespace().map(|x| x.parse().unwrap()).collect();
  a.sort();
  let m = a[a.len() / 2];
  let ans = a.into_iter().fold(0, |acc, x| acc + (x - m).abs());
  println!("{}", ans);
}

0