結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
53,960 KB
testcase_01 AC 137 ms
54,072 KB
testcase_02 AC 133 ms
53,876 KB
testcase_03 AC 129 ms
54,112 KB
testcase_04 AC 208 ms
56,476 KB
testcase_05 AC 208 ms
56,680 KB
testcase_06 AC 208 ms
56,860 KB
testcase_07 AC 206 ms
56,540 KB
testcase_08 AC 206 ms
56,560 KB
testcase_09 AC 208 ms
56,500 KB
testcase_10 AC 212 ms
57,100 KB
testcase_11 AC 204 ms
56,640 KB
testcase_12 AC 205 ms
56,536 KB
testcase_13 AC 194 ms
56,960 KB
testcase_14 AC 209 ms
56,728 KB
testcase_15 AC 207 ms
56,736 KB
testcase_16 AC 208 ms
56,508 KB
testcase_17 AC 204 ms
56,744 KB
testcase_18 AC 206 ms
56,884 KB
testcase_19 AC 209 ms
56,776 KB
testcase_20 AC 202 ms
56,448 KB
testcase_21 AC 208 ms
56,736 KB
testcase_22 AC 201 ms
56,680 KB
testcase_23 AC 211 ms
57,244 KB
testcase_24 AC 212 ms
56,956 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]);
    }
    long 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