結果

問題 No.178 美しいWhitespace (1)
ユーザー koukonkokoukonko
提出日時 2015-12-14 12:57:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,210 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 52,020 KB
最終ジャッジ日時 2023-10-13 16:28:54
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,312 KB
testcase_01 AC 44 ms
49,584 KB
testcase_02 AC 39 ms
49,352 KB
testcase_03 AC 39 ms
49,328 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 39 ms
49,332 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 39 ms
49,544 KB
testcase_12 AC 38 ms
49,492 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 42 ms
49,320 KB
testcase_19 WA -
testcase_20 AC 40 ms
49,648 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 73 ms
51,776 KB
testcase_24 AC 70 ms
50,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		}
	}
}
0