結果

問題 No.178 美しいWhitespace (1)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-20 22:49:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 2,980 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 57,392 KB
最終ジャッジ日時 2024-04-19 23:25:05
合計ジャッジ時間 8,164 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
53,904 KB
testcase_01 AC 113 ms
53,896 KB
testcase_02 AC 114 ms
54,228 KB
testcase_03 AC 105 ms
53,148 KB
testcase_04 AC 181 ms
56,756 KB
testcase_05 AC 179 ms
57,028 KB
testcase_06 AC 178 ms
56,756 KB
testcase_07 AC 183 ms
56,768 KB
testcase_08 AC 177 ms
56,556 KB
testcase_09 AC 176 ms
56,564 KB
testcase_10 AC 185 ms
57,196 KB
testcase_11 AC 181 ms
56,560 KB
testcase_12 AC 179 ms
56,520 KB
testcase_13 AC 184 ms
56,720 KB
testcase_14 AC 175 ms
56,604 KB
testcase_15 AC 181 ms
56,844 KB
testcase_16 AC 174 ms
56,940 KB
testcase_17 AC 183 ms
57,392 KB
testcase_18 AC 179 ms
56,776 KB
testcase_19 AC 177 ms
56,856 KB
testcase_20 AC 176 ms
56,656 KB
testcase_21 AC 177 ms
56,836 KB
testcase_22 AC 173 ms
56,476 KB
testcase_23 AC 183 ms
56,612 KB
testcase_24 AC 178 ms
56,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise103{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    long[] sum = new long[n];
    long max = 0;
    for(int i = 0; i < n; i++){
      long a = sc.nextLong();
      long b = sc.nextLong() * 4;
      sum[i] = a + b;
      max = Math.max(max, a + b);
    }
    long answer = 0;
    for(int i = 0; i < n; i++){
      if((max - sum[i]) % 2 == 0){
        answer += (max - sum[i]) / 2;
      }else{
        System.out.println(-1);
        return;
      }
    }
    System.out.println(answer);
  }
}
0