結果

問題 No.178 美しいWhitespace (1)
ユーザー norioc
提出日時 2017-08-12 06:02:08
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 106,140 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 21:32:31
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

ulong calc(int[] xs) {
    int max = xs.maxElement;
    ulong ans = 0;
    foreach (x; xs) {
        if ((max - x) % 2 == 1) {
            return -1;
        }
        ans += max - x;
    }
    return ans / 2;
}

void main() {
    int n = readint();

    int[] xs;
    for (int i = 0; i < n; i++) {
        auto ys = readints();
        int a = ys[0], b = ys[1];
        xs ~= a + 4 * b;
    }

    writeln(calc(xs));
}
0