結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,460 KB
testcase_01 AC 135 ms
41,088 KB
testcase_02 AC 133 ms
41,372 KB
testcase_03 AC 135 ms
41,568 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 209 ms
43,272 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 213 ms
43,284 KB
testcase_12 AC 215 ms
43,528 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 214 ms
43,112 KB
testcase_19 WA -
testcase_20 AC 211 ms
43,452 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 213 ms
43,152 KB
testcase_24 AC 216 ms
43,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

		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