結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2017-08-12 06:00:46 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 104,080 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 21:30:52 |
合計ジャッジ時間 | 1,655 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 14 |
ソースコード
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; } int calc(int[] xs) { int max = xs.maxElement; int 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)); }