結果

問題 No.178 美しいWhitespace (1)
ユーザー fal_rndfal_rnd
提出日時 2018-04-18 09:57:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 76,608 KB
実行使用メモリ 57,040 KB
最終ジャッジ日時 2023-09-09 11:21:08
合計ジャッジ時間 8,370 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,624 KB
testcase_01 AC 122 ms
55,892 KB
testcase_02 AC 121 ms
56,084 KB
testcase_03 AC 126 ms
55,376 KB
testcase_04 AC 188 ms
57,040 KB
testcase_05 AC 183 ms
56,404 KB
testcase_06 AC 186 ms
56,516 KB
testcase_07 AC 180 ms
56,544 KB
testcase_08 AC 183 ms
56,808 KB
testcase_09 AC 180 ms
56,572 KB
testcase_10 AC 180 ms
56,540 KB
testcase_11 AC 179 ms
56,488 KB
testcase_12 AC 180 ms
56,036 KB
testcase_13 AC 180 ms
56,792 KB
testcase_14 AC 179 ms
56,816 KB
testcase_15 AC 182 ms
56,448 KB
testcase_16 AC 187 ms
56,968 KB
testcase_17 AC 181 ms
56,804 KB
testcase_18 AC 183 ms
56,804 KB
testcase_19 AC 180 ms
56,668 KB
testcase_20 AC 177 ms
56,420 KB
testcase_21 AC 182 ms
56,804 KB
testcase_22 AC 178 ms
56,732 KB
testcase_23 AC 179 ms
56,192 KB
testcase_24 AC 184 ms
56,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;
class Main {
    static Scanner s=new Scanner(System.in);
    static int gInt(){return Integer.parseInt(s.next());}
    public static void main(String[]$){
        int n=gInt();
        int[]a=IntStream.range(0,n).map(i->gInt()+gInt()*4).sorted().toArray();
        
        long r=0;
        for(int i=0;i<n-1;i++){
            int v=a[n-1]-a[i];
            if(v%2==1){
                System.out.println(-1);
                return;
            }
            r+=v/2;
        }
        System.out.println(r);
    }
}
0