結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2015-12-14 13:03:53 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 1,227 bytes |
コンパイル時間 | 2,213 ms |
コンパイル使用メモリ | 77,892 KB |
実行使用メモリ | 38,376 KB |
最終ジャッジ日時 | 2024-09-15 12:29:04 |
合計ジャッジ時間 | 4,897 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
package yukicoder; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static void main(String[] args) { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); try { int N = Integer.parseInt(read.readLine()); int i = 0, eo; List<Long> list = new ArrayList<>(N); String[] box = read.readLine().split(" "); long total = 0; total = Integer.parseInt(box[0]); total += Integer.parseInt(box[1]) * 4; list.add(total); if (total % 2 == 0) { eo = 0; } else { eo = 1; } long max = total; while (i++ < N - 1) { box = read.readLine().split(" "); total = Integer.parseInt(box[0]); total += Integer.parseInt(box[1]) * 4; list.add(total); if (total % 2 != eo) { break; } else { if (max < total) { max = total; } } } if (i < N) { System.out.println(-1); } else { Iterator<Long> it = list.iterator(); long ans = 0; while (it.hasNext()) { ans += max - it.next(); } System.out.println(ans / 2); } } catch (Exception e) { e.printStackTrace(); } } }