結果

問題 No.178 美しいWhitespace (1)
ユーザー spacenautspacenaut
提出日時 2016-05-22 18:32:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 75,484 KB
実行使用メモリ 43,796 KB
最終ジャッジ日時 2024-04-16 06:49:06
合計ジャッジ時間 8,008 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,264 KB
testcase_01 AC 134 ms
41,636 KB
testcase_02 AC 118 ms
39,932 KB
testcase_03 AC 134 ms
40,952 KB
testcase_04 AC 208 ms
43,536 KB
testcase_05 AC 209 ms
43,292 KB
testcase_06 AC 209 ms
43,472 KB
testcase_07 AC 211 ms
43,512 KB
testcase_08 AC 212 ms
43,468 KB
testcase_09 AC 207 ms
43,424 KB
testcase_10 AC 210 ms
43,328 KB
testcase_11 AC 216 ms
43,248 KB
testcase_12 AC 212 ms
43,796 KB
testcase_13 AC 211 ms
43,324 KB
testcase_14 AC 212 ms
43,600 KB
testcase_15 AC 212 ms
43,196 KB
testcase_16 AC 211 ms
43,436 KB
testcase_17 AC 211 ms
43,492 KB
testcase_18 AC 212 ms
43,500 KB
testcase_19 AC 215 ms
43,596 KB
testcase_20 AC 215 ms
43,412 KB
testcase_21 AC 214 ms
43,120 KB
testcase_22 AC 204 ms
43,024 KB
testcase_23 AC 214 ms
43,440 KB
testcase_24 AC 217 ms
43,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class No0178{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long sp, tb, temp;
		long cnt = 0;
		ArrayList<Long> a = new ArrayList<Long>();

		for(int i = 0; i < n; i++){
			sp = sc.nextInt();
			tb = sc.nextInt() * 4;
			a.add(sp + tb);
		}
		
		Collections.sort(a);
		Collections.reverse(a);

		for(int i = 1; i < n; i++){
			temp = a.get(0) - a.get(i);
			if(temp % 2 != 0){
				cnt = -1;
				break;
			}else{
				cnt = cnt + (temp / 2);
			}
		}
		System.out.println(cnt);
	}
}
0