結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2017-08-12 06:02:41 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 665 bytes |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 104,540 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 21:32:37 |
| 合計ジャッジ時間 | 1,573 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
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;
}
long calc(int[] xs) {
int max = xs.maxElement;
long 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));
}
norioc