結果

問題 No.609 Noelちゃんと星々
ユーザー motimoti
提出日時 2018-05-24 00:29:12
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 327 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 18,404 KB
最終ジャッジ日時 2023-09-11 02:04:29
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,260 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 36 ms
9,556 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 48 ms
11,296 KB
testcase_08 AC 13 ms
6,088 KB
testcase_09 AC 31 ms
8,908 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 75 ms
14,212 KB
testcase_13 WA -
testcase_14 AC 9 ms
5,420 KB
testcase_15 WA -
testcase_16 AC 99 ms
17,928 KB
testcase_17 AC 81 ms
15,328 KB
testcase_18 AC 26 ms
8,320 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my $n = <>;
my @ys = split / /, <>;
@ys = sort { $a <=> $b } @ys;
my $target;
if ($n % 2) {
  $target = $ys[$n / 2];
} else {
  my $lpos = int($n / 2);
  $target = ($ys[$lpos] + $ys[$lpos + 1]) / 2;
}
my $ans = 0;
for my $e (@ys) {
  $ans += abs($e - $target);
}
print "$ans\n";
0