結果

問題 No.178 美しいWhitespace (1)
ユーザー kou6839kou6839
提出日時 2015-04-16 01:45:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 71,084 KB
実行使用メモリ 42,052 KB
最終ジャッジ日時 2023-09-17 20:46:18
合計ジャッジ時間 7,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
39,380 KB
testcase_01 AC 119 ms
39,656 KB
testcase_02 AC 117 ms
39,040 KB
testcase_03 AC 118 ms
39,260 KB
testcase_04 AC 190 ms
41,524 KB
testcase_05 AC 195 ms
41,368 KB
testcase_06 AC 195 ms
41,988 KB
testcase_07 AC 193 ms
40,908 KB
testcase_08 AC 191 ms
41,248 KB
testcase_09 AC 192 ms
41,168 KB
testcase_10 AC 194 ms
41,676 KB
testcase_11 AC 194 ms
42,052 KB
testcase_12 AC 190 ms
40,908 KB
testcase_13 AC 192 ms
41,180 KB
testcase_14 AC 194 ms
41,176 KB
testcase_15 AC 194 ms
41,688 KB
testcase_16 AC 190 ms
41,864 KB
testcase_17 AC 193 ms
41,440 KB
testcase_18 AC 189 ms
41,716 KB
testcase_19 AC 195 ms
41,208 KB
testcase_20 AC 192 ms
41,276 KB
testcase_21 AC 190 ms
41,540 KB
testcase_22 AC 184 ms
41,068 KB
testcase_23 AC 196 ms
41,008 KB
testcase_24 AC 191 ms
42,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main {
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] space = new int[n];
		int max=0;
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			max=Math.max(max, a+b*4);
			space[i]=a+b*4;
		}
		long ans=0;
		for(int i=0;i<n;i++){
			if( (max-space[i])%2!=0){
				System.out.println(-1);
				return;
			}else{
				ans+=(max-space[i])/2;
			}
		}
		System.out.println(ans);
	}
}
0