結果

問題 No.178 美しいWhitespace (1)
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-23 06:49:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 74,244 KB
実行使用メモリ 57,140 KB
最終ジャッジ日時 2024-04-10 10:48:05
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
53,976 KB
testcase_01 AC 131 ms
54,016 KB
testcase_02 AC 131 ms
53,988 KB
testcase_03 AC 132 ms
54,140 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 205 ms
56,784 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 210 ms
56,896 KB
testcase_12 AC 209 ms
56,652 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 209 ms
56,664 KB
testcase_19 WA -
testcase_20 AC 209 ms
56,880 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 208 ms
56,848 KB
testcase_24 AC 207 ms
56,768 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 odd = 0;
    int even = 0;
    long max = 0;
    long[] a = new long[N];
    long[] b = new long[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextLong();
      b[i] = sc.nextLong();
      if(a[i] % 2 == 0) {
        even++;
      } else {
        odd++;
      }
      max = Math.max(max, a[i] + 4 * b[i]);
    }
    int ans = 0;
    if(even == 0 || odd == 0) {
      for(int i = 0; i < N; i++) {
        ans += ((max - a[i] - 4 * b[i]) / 2);
      }
    } else {
      ans = -1;
    }
    System.out.println(ans);
  }
}
0