結果

問題 No.178 美しいWhitespace (1)
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 08:13:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 71,308 KB
実行使用メモリ 60,136 KB
最終ジャッジ日時 2023-08-17 04:17:31
合計ジャッジ時間 8,016 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,072 KB
testcase_01 AC 124 ms
55,476 KB
testcase_02 AC 121 ms
55,692 KB
testcase_03 AC 121 ms
56,000 KB
testcase_04 AC 196 ms
58,364 KB
testcase_05 AC 196 ms
58,644 KB
testcase_06 AC 200 ms
58,116 KB
testcase_07 AC 200 ms
58,304 KB
testcase_08 AC 219 ms
58,508 KB
testcase_09 AC 214 ms
58,776 KB
testcase_10 AC 209 ms
58,108 KB
testcase_11 AC 208 ms
58,384 KB
testcase_12 AC 217 ms
60,136 KB
testcase_13 AC 218 ms
58,940 KB
testcase_14 AC 214 ms
58,248 KB
testcase_15 AC 217 ms
58,436 KB
testcase_16 AC 215 ms
58,524 KB
testcase_17 AC 210 ms
58,492 KB
testcase_18 AC 208 ms
58,624 KB
testcase_19 AC 208 ms
58,868 KB
testcase_20 AC 219 ms
58,368 KB
testcase_21 AC 196 ms
58,356 KB
testcase_22 AC 185 ms
58,552 KB
testcase_23 AC 197 ms
58,416 KB
testcase_24 AC 193 ms
58,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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