結果

問題 No.178 美しいWhitespace (1)
ユーザー htensaihtensai
提出日時 2020-05-13 11:55:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 71,512 KB
実行使用メモリ 59,144 KB
最終ジャッジ日時 2023-10-12 16:56:26
合計ジャッジ時間 7,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,852 KB
testcase_01 AC 126 ms
55,580 KB
testcase_02 AC 121 ms
55,444 KB
testcase_03 AC 122 ms
55,440 KB
testcase_04 AC 189 ms
58,756 KB
testcase_05 AC 196 ms
58,508 KB
testcase_06 AC 198 ms
58,460 KB
testcase_07 AC 193 ms
58,372 KB
testcase_08 AC 193 ms
58,528 KB
testcase_09 AC 198 ms
58,560 KB
testcase_10 AC 195 ms
58,004 KB
testcase_11 AC 196 ms
58,660 KB
testcase_12 AC 194 ms
58,388 KB
testcase_13 AC 193 ms
58,024 KB
testcase_14 AC 199 ms
58,220 KB
testcase_15 AC 199 ms
58,324 KB
testcase_16 AC 197 ms
58,580 KB
testcase_17 AC 194 ms
58,752 KB
testcase_18 AC 193 ms
57,964 KB
testcase_19 AC 196 ms
59,144 KB
testcase_20 AC 199 ms
58,624 KB
testcase_21 AC 195 ms
56,112 KB
testcase_22 AC 186 ms
58,488 KB
testcase_23 AC 194 ms
58,084 KB
testcase_24 AC 194 ms
58,224 KB
権限があれば一括ダウンロードができます

ソースコード

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]);
		}
		long 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