結果

問題 No.178 美しいWhitespace (1)
ユーザー ちよちゃんちよちゃん
提出日時 2016-06-07 00:12:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,022 bytes
コンパイル時間 3,506 ms
コンパイル使用メモリ 78,748 KB
実行使用メモリ 57,216 KB
最終ジャッジ日時 2024-04-17 05:26:12
合計ジャッジ時間 9,559 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
41,156 KB
testcase_01 WA -
testcase_02 AC 128 ms
41,184 KB
testcase_03 AC 132 ms
41,068 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 203 ms
43,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 209 ms
43,368 KB
testcase_12 AC 204 ms
43,224 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 208 ms
43,636 KB
testcase_19 WA -
testcase_20 AC 209 ms
43,184 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 197 ms
43,612 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

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 a_flg = false;
			boolean b_flg = false;
			
			ArrayList<Integer> array = new ArrayList<Integer>();
			
			for (int i = 0; i < n ; i++ ) {
				a[i] = scan.nextInt();
				b[i] = scan.nextInt();
				
			}
			scan.close();
			
			int ans = 0;
			for (int i = 0; i < n ; i++ ) {
				ans = a[i] + 4 * b[i];
				if(ans != 0) {
					if(ans % 2 == 0 ){
						a_flg = true;
					}else if(ans % 3 == 0 ){
						b_flg = true;
					}
				}
				array.add(ans);
			}
			
			Collections.sort(array);
			int max = Collections.max(array);
			
			ans = 0;
			for(Integer num : array){
				ans += ((max - num) / 2); 
			}
			
			if( a_flg == b_flg == true){
				System.out.println(-1);
			}else {
				System.out.println(ans);
			}
	}

}
0