結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2015-12-29 17:25:29 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 933 bytes |
コンパイル時間 | 2,004 ms |
コンパイル使用メモリ | 77,528 KB |
実行使用メモリ | 51,576 KB |
最終ジャッジ日時 | 2024-09-19 08:25:22 |
合計ジャッジ時間 | 4,680 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 14 |
ソースコード
import java.io.*; import java.util.*; import java.math.*; class Main178 { public static void out (Object out) { System.out.println(out); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] nums = new int[n]; String[] line = br.readLine().split(" "); int a = Integer.parseInt(line[0]); nums[0] = a + Integer.parseInt(line[1]) * 4; int max = nums[0]; boolean isImpossible = false; for (int i = 1; i < n; i++) { line = br.readLine().split(" "); int a2 = Integer.parseInt(line[0]); if (a % 2 != a2 % 2) { isImpossible = true; break; } nums[i] = a2 + Integer.parseInt(line[1]) * 4; max = Math.max(max , nums[i]); } //out("max = " + max); int ans = 0; for (int m : nums) ans += (max - m); out(isImpossible ? -1 : ans / 2); } }