結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー mnrn
提出日時 2017-07-23 16:53:15
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 1,000 ms
+ 147µs
コード長 343 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,529 ms
コンパイル使用メモリ 128,512 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-26 04:19:45
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;

void main() {
    int N = to!int(readln().strip());
    int[] lst = readln().strip().split().map!(to!int)().array();

    lst.sort!();
    if (N % 2 == 0) {
        writeln((lst[N / 2 - 1] + lst[N / 2]) / 2.0);
    }
    else {
        writeln(lst[N / 2]);
    }
}
0