結果

問題 No.178 美しいWhitespace (1)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-20 22:44:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 595 bytes
コンパイル時間 5,893 ms
コンパイル使用メモリ 74,140 KB
実行使用メモリ 59,144 KB
最終ジャッジ日時 2024-04-19 23:23:42
合計ジャッジ時間 10,653 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
53,900 KB
testcase_01 AC 116 ms
53,904 KB
testcase_02 AC 122 ms
54,008 KB
testcase_03 AC 113 ms
53,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 182 ms
57,128 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 194 ms
56,596 KB
testcase_12 AC 183 ms
56,824 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 191 ms
56,856 KB
testcase_19 WA -
testcase_20 AC 190 ms
56,748 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 189 ms
56,720 KB
testcase_24 AC 186 ms
56,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] sum = new int[n];
    int max = 0;
    for(int i = 0; i < n; i++){
      int a = sc.nextInt();
      int b = sc.nextInt() * 4;
      sum[i] = a + b;
      max = Math.max(max, a + b);
    }
    int 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