結果

問題 No.178 美しいWhitespace (1)
ユーザー ちよちゃんちよちゃん
提出日時 2016-06-07 00:36:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 3,942 ms
コンパイル使用メモリ 79,324 KB
実行使用メモリ 43,696 KB
最終ジャッジ日時 2024-04-17 05:26:57
合計ジャッジ時間 9,813 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,364 KB
testcase_01 AC 121 ms
40,244 KB
testcase_02 AC 120 ms
40,528 KB
testcase_03 AC 116 ms
40,080 KB
testcase_04 AC 205 ms
43,688 KB
testcase_05 AC 204 ms
43,512 KB
testcase_06 AC 205 ms
43,636 KB
testcase_07 AC 207 ms
43,332 KB
testcase_08 AC 201 ms
43,364 KB
testcase_09 AC 202 ms
43,568 KB
testcase_10 AC 207 ms
43,504 KB
testcase_11 AC 202 ms
43,260 KB
testcase_12 AC 197 ms
43,292 KB
testcase_13 AC 201 ms
43,424 KB
testcase_14 AC 203 ms
43,312 KB
testcase_15 AC 202 ms
43,696 KB
testcase_16 AC 196 ms
43,668 KB
testcase_17 AC 202 ms
43,388 KB
testcase_18 AC 205 ms
43,524 KB
testcase_19 AC 201 ms
43,648 KB
testcase_20 AC 207 ms
43,528 KB
testcase_21 AC 207 ms
43,512 KB
testcase_22 AC 199 ms
43,316 KB
testcase_23 AC 202 ms
43,672 KB
testcase_24 AC 205 ms
43,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Yuki178 {
	
	public static void main(String[] args) {
	
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();
			int a[] = new int[n];
			int b[] = new int[n];
			boolean flg = true;
			
			ArrayList<Long> array = new ArrayList<Long>();
			
			for (int i = 0; i < n ; i++ ) {
				a[i] = scan.nextInt();
				b[i] = scan.nextInt();
				
			}
			scan.close();
			
		    long ans = 0;
			for (int i = 0; i < n ; i++ ) {
				ans = a[i] + 4 * b[i];
				array.add(ans);
			}
			
			Collections.sort(array);
			long max = Collections.max(array);
			
			long big_ans = 0;
			for(long num : array){
				big_ans += ((max - num) / 2);
				if((max - num) % 2 == 1){ 
					flg = false;
				}
			}

			if (flg == true){
				System.out.println(big_ans);
			} else {
				System.out.println(-1);
			}
	}

}
0