結果

問題 No.609 Noelちゃんと星々
ユーザー nanaenanae
提出日時 2017-12-09 00:27:27
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 2,525 ms
コンパイル使用メモリ 100,896 KB
実行使用メモリ 6,460 KB
最終ジャッジ日時 2023-09-03 17:21:24
合計ジャッジ時間 2,573 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
5,908 KB
testcase_01 AC 15 ms
4,380 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 14 ms
5,128 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 35 ms
5,812 KB
testcase_06 AC 30 ms
5,916 KB
testcase_07 AC 18 ms
5,664 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 23 ms
5,804 KB
testcase_11 AC 21 ms
4,400 KB
testcase_12 AC 26 ms
6,008 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 31 ms
6,460 KB
testcase_16 AC 36 ms
6,396 KB
testcase_17 AC 28 ms
5,696 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 30 ms
6,140 KB
testcase_20 AC 37 ms
5,844 KB
testcase_21 AC 36 ms
5,848 KB
testcase_22 AC 37 ms
6,368 KB
testcase_23 AC 37 ms
6,384 KB
testcase_24 AC 37 ms
5,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);

    auto y = readln.split.to!(int[]);
    y.sort();
    
    long ans;

    foreach (i ; 0 .. n) {
        ans += abs(y[i] - y[n/2]);
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0