結果

問題 No.178 美しいWhitespace (1)
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 00:20:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 71,860 KB
実行使用メモリ 58,960 KB
最終ジャッジ日時 2023-09-17 04:56:00
合計ジャッジ時間 7,903 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,768 KB
testcase_01 AC 126 ms
57,960 KB
testcase_02 AC 125 ms
55,592 KB
testcase_03 AC 126 ms
55,728 KB
testcase_04 AC 202 ms
58,544 KB
testcase_05 AC 199 ms
58,208 KB
testcase_06 AC 198 ms
58,444 KB
testcase_07 AC 197 ms
57,652 KB
testcase_08 AC 204 ms
58,536 KB
testcase_09 AC 201 ms
58,820 KB
testcase_10 AC 198 ms
58,484 KB
testcase_11 AC 199 ms
58,892 KB
testcase_12 AC 193 ms
58,396 KB
testcase_13 AC 202 ms
58,552 KB
testcase_14 AC 199 ms
58,960 KB
testcase_15 AC 202 ms
58,436 KB
testcase_16 AC 199 ms
58,360 KB
testcase_17 AC 199 ms
58,732 KB
testcase_18 AC 201 ms
58,840 KB
testcase_19 AC 199 ms
58,204 KB
testcase_20 AC 202 ms
58,164 KB
testcase_21 AC 200 ms
58,036 KB
testcase_22 AC 195 ms
58,392 KB
testcase_23 AC 199 ms
57,992 KB
testcase_24 AC 199 ms
57,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner (System.in);
        int n = koko.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i =0; i<n; i++){
            a[i] = koko.nextInt();
            b[i] = koko.nextInt();
        }
        int max=0;
        int[] white = new int[n];
        for(int i =0; i<n; i++){
            white[i] = a[i]+4*b[i];
            max = Math.max(max,white[i]);
        }
        long need=0;
        for(int i=0; i<n; i++){
            if((max-white[i])%2==0){
            need = need + (max-white[i])/2;
            }else{
                need = -1;
                break;
            }
        }
        System.out.println(need);

    }
}
0