結果

問題 No.609 Noelちゃんと星々
ユーザー ikdikd
提出日時 2017-12-09 00:06:10
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 97,592 KB
実行使用メモリ 6,340 KB
最終ジャッジ日時 2023-09-03 17:21:05
合計ジャッジ時間 3,970 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
5,644 KB
testcase_01 AC 14 ms
5,440 KB
testcase_02 AC 10 ms
4,376 KB
testcase_03 AC 13 ms
5,216 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 32 ms
6,336 KB
testcase_06 AC 27 ms
6,160 KB
testcase_07 AC 17 ms
5,324 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 21 ms
5,916 KB
testcase_11 AC 20 ms
5,656 KB
testcase_12 AC 23 ms
5,640 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 28 ms
5,884 KB
testcase_16 AC 33 ms
5,868 KB
testcase_17 AC 26 ms
5,908 KB
testcase_18 AC 10 ms
4,508 KB
testcase_19 AC 28 ms
6,056 KB
testcase_20 AC 33 ms
6,340 KB
testcase_21 AC 34 ms
6,140 KB
testcase_22 AC 34 ms
6,100 KB
testcase_23 AC 34 ms
5,972 KB
testcase_24 AC 33 ms
5,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n; rd(n);
  auto a=readln.split.to!(long[]);

  sort(a);
  auto md=a[n/2];
  writeln(reduce!((r, e)=>r+(e-md).abs)(0L, a));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) stderr.write(e, " ");
  stderr.writeln;
}
0