結果

問題 No.609 Noelちゃんと星々
ユーザー te-shte-sh
提出日時 2017-12-11 10:27:39
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 97,848 KB
実行使用メモリ 6,692 KB
最終ジャッジ日時 2023-09-03 17:25:18
合計ジャッジ時間 2,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
6,692 KB
testcase_01 AC 14 ms
5,496 KB
testcase_02 AC 10 ms
4,376 KB
testcase_03 AC 14 ms
5,440 KB
testcase_04 AC 7 ms
4,384 KB
testcase_05 AC 34 ms
6,040 KB
testcase_06 AC 29 ms
6,564 KB
testcase_07 AC 18 ms
5,892 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 22 ms
4,428 KB
testcase_11 AC 21 ms
6,168 KB
testcase_12 AC 25 ms
6,416 KB
testcase_13 AC 5 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 30 ms
6,492 KB
testcase_16 AC 33 ms
5,900 KB
testcase_17 AC 26 ms
5,696 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 29 ms
6,564 KB
testcase_20 AC 35 ms
6,648 KB
testcase_21 AC 35 ms
6,132 KB
testcase_22 AC 35 ms
5,964 KB
testcase_23 AC 35 ms
5,872 KB
testcase_24 AC 36 ms
5,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions

void main()
{
  auto n = readln.chomp.to!int;
  auto y = readln.split.to!(int[]);
  y.sort();

  auto m = n&1 ? y[n/2] : (y[n/2-1]+y[n/2])/2;
  auto ans = 0L;
  foreach (yi; y) ans += (yi-m).abs;

  writeln(ans);
}
0