結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
koukonko
|
| 提出日時 | 2015-12-14 12:57:21 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,210 bytes |
| コンパイル時間 | 2,528 ms |
| コンパイル使用メモリ | 78,280 KB |
| 実行使用メモリ | 38,288 KB |
| 最終ジャッジ日時 | 2024-09-15 12:28:56 |
| 合計ジャッジ時間 | 5,217 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 14 |
ソースコード
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<Integer> list = new ArrayList<>(N);
String[] box = read.readLine().split(" ");
int 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;
}
int 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<Integer> it = list.iterator();
int ans = 0;
while (it.hasNext()) {
ans += max - it.next();
}
System.out.println(ans / 2);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
koukonko