結果

問題 No.178 美しいWhitespace (1)
ユーザー TatsuDX
提出日時 2016-09-09 00:17:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 3,619 ms
コンパイル使用メモリ 77,412 KB
実行使用メモリ 56,948 KB
最終ジャッジ日時 2024-11-15 22:37:22
合計ジャッジ時間 8,618 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong(), sum = 0, max = 0, t;
		boolean a = false, b = false;
		for(int i = 0; i < n; i++){
			t = sc.nextLong() + sc.nextLong() * 4;
			if(t % 2 == 0){
				a = true;
			} else {
				b = true;
			}
			max = Math.max(max, t);
			sum += t;
		}
		if(a && b){
			System.out.println(-1);
			return;
		}
		System.out.println((max*n - sum)/2);
	}
}
0