結果

問題 No.178 美しいWhitespace (1)
ユーザー discoNekodiscoNeko
提出日時 2016-04-29 14:38:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 78,456 KB
実行使用メモリ 51,752 KB
最終ジャッジ日時 2024-04-15 05:23:05
合計ジャッジ時間 5,581 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
50,060 KB
testcase_01 AC 59 ms
50,240 KB
testcase_02 AC 58 ms
50,012 KB
testcase_03 AC 57 ms
50,296 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 94 ms
51,416 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 93 ms
51,484 KB
testcase_12 AC 92 ms
51,036 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 92 ms
50,932 KB
testcase_19 WA -
testcase_20 AC 83 ms
51,392 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 94 ms
51,340 KB
testcase_24 AC 95 ms
51,584 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());
		int[] sum = new int[n];
		int max = 0;
		for(int i = 0; i < n; i++){
			String[] str = br.readLine().split(" ");
			sum[i] = Integer.parseInt(str[0]);
			sum[i] += 4*Integer.parseInt(str[1]);
			max = Math.max(max,sum[i]);
		}
		int cnt = 0;
		for(int i = 0; i < n; i++){
			int 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