結果

問題 No.178 美しいWhitespace (1)
ユーザー htensai
提出日時 2020-05-13 11:53:59
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 74,300 KB
実行使用メモリ 58,948 KB
最終ジャッジ日時 2024-09-14 15:31:20
合計ジャッジ時間 8,062 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt() + sc.nextInt() * 4;
		    max = Math.max(max, arr[i]);
		}
		int count = 0;
		for (int x : arr) {
		    if (x % 2 != max % 2) {
		        System.out.println(-1);
		        return;
		    }
		    count += (max - x) / 2;
		}
		System.out.println(count);
	}
}
0