結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー spacenaut
提出日時 2016-05-22 18:30:03
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 566 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,690 ms
コンパイル使用メモリ 90,796 KB
実行使用メモリ 48,136 KB
最終ジャッジ日時 2026-09-11 06:35:11
合計ジャッジ時間 6,223 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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