結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2018-12-01 16:00:19 |
言語 | Perl (5.40.0) |
結果 |
AC
|
実行時間 | 9 ms / 1,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 6,684 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 23:59:51 |
合計ジャッジ時間 | 1,534 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use strict; use warnings; use feature qw/say/; # https://yukicoder.me/problems/746 my $N = <>; my $A = <>; chomp ($N,$A); # 数値としてのソートが必要 my @a = sort { $a <=> $b } ( split / /, $A ); my $index = int( $N / 2 ); # 与えられる数が偶数か奇数で分ける if ( $N % 2 == 0 ) { # 偶数 my $central_sum = $a[$index - 1] + $a[$index]; say $central_sum / 2; } else { # 奇数 say $a[$index]; }