結果

問題 No.178 美しいWhitespace (1)
ユーザー k_kadorak_kadora
提出日時 2015-05-27 15:09:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 4,195 ms
コンパイル使用メモリ 71,920 KB
実行使用メモリ 58,940 KB
最終ジャッジ日時 2023-09-20 15:56:25
合計ジャッジ時間 10,070 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,632 KB
testcase_01 AC 123 ms
55,688 KB
testcase_02 AC 123 ms
56,112 KB
testcase_03 AC 126 ms
55,976 KB
testcase_04 AC 199 ms
58,048 KB
testcase_05 AC 200 ms
58,432 KB
testcase_06 AC 197 ms
58,672 KB
testcase_07 AC 196 ms
57,108 KB
testcase_08 AC 196 ms
58,328 KB
testcase_09 AC 198 ms
58,144 KB
testcase_10 AC 195 ms
58,384 KB
testcase_11 AC 197 ms
58,480 KB
testcase_12 AC 195 ms
58,492 KB
testcase_13 AC 197 ms
58,648 KB
testcase_14 AC 196 ms
57,996 KB
testcase_15 AC 195 ms
58,384 KB
testcase_16 AC 197 ms
58,300 KB
testcase_17 AC 196 ms
58,736 KB
testcase_18 AC 199 ms
58,632 KB
testcase_19 AC 194 ms
57,776 KB
testcase_20 AC 195 ms
58,028 KB
testcase_21 AC 196 ms
58,940 KB
testcase_22 AC 192 ms
58,768 KB
testcase_23 AC 197 ms
58,680 KB
testcase_24 AC 201 ms
57,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Whitespace{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		long max=0,sum=0,res = 0;
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0;i<n;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			sum = sum + (a[i] % 2);
			if(a[i] + b[i]*4 >max)max = a[i] + b[i] * 4;
		}
		if(sum == n || sum == 0){
			for(int i = 0;i<n;i++){
				res = res + (max - (a[i] + b[i] *4))/2;
			}
			System.out.println(res);
		}else{
			System.out.println(-1);
		}
	}
}
0