結果

問題 No.178 美しいWhitespace (1)
ユーザー discoNekodiscoNeko
提出日時 2016-04-29 14:49:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 78,208 KB
実行使用メモリ 51,580 KB
最終ジャッジ日時 2024-04-15 05:23:14
合計ジャッジ時間 4,872 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,048 KB
testcase_01 AC 51 ms
50,124 KB
testcase_02 AC 50 ms
50,316 KB
testcase_03 AC 49 ms
50,240 KB
testcase_04 AC 72 ms
51,288 KB
testcase_05 AC 84 ms
51,348 KB
testcase_06 AC 84 ms
51,228 KB
testcase_07 AC 86 ms
51,168 KB
testcase_08 AC 85 ms
51,288 KB
testcase_09 AC 83 ms
51,372 KB
testcase_10 AC 85 ms
51,580 KB
testcase_11 AC 83 ms
50,916 KB
testcase_12 AC 83 ms
51,296 KB
testcase_13 AC 83 ms
50,944 KB
testcase_14 AC 82 ms
50,956 KB
testcase_15 AC 85 ms
51,056 KB
testcase_16 AC 85 ms
51,260 KB
testcase_17 AC 76 ms
50,892 KB
testcase_18 AC 73 ms
51,060 KB
testcase_19 AC 84 ms
51,296 KB
testcase_20 AC 87 ms
50,936 KB
testcase_21 AC 74 ms
51,228 KB
testcase_22 AC 79 ms
51,340 KB
testcase_23 AC 87 ms
51,248 KB
testcase_24 AC 85 ms
51,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		long[] sum = new long[n];
		long max = 0;
		for(int i = 0; i < n; i++){
			String[] str = br.readLine().split(" ");
			sum[i] = Long.parseLong(str[0]);
			sum[i] += 4*Long.parseLong(str[1]);
			max = Math.max(max,sum[i]);
		}
		long cnt = 0;
		for(int i = 0; i < n; i++){
			long k = max - sum[i];
			if(k%2!=0){
				sb.append(-1);
				System.out.println(sb);
				return;
			}
			cnt += k/2;
		}
		sb.append(cnt);
		System.out.println(sb);
	}
}
0