結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー takeya_okino
提出日時 2017-06-23 06:55:35
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 116 ms / 2,000 ms
+ 109µs
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,397 ms
コンパイル使用メモリ 85,252 KB
実行使用メモリ 49,044 KB
最終ジャッジ日時 2026-09-08 23:07:18
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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