結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             takeya_okino
                         | 
                    
| 提出日時 | 2017-06-23 06:49:11 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 686 bytes | 
| コンパイル時間 | 2,382 ms | 
| コンパイル使用メモリ | 74,104 KB | 
| 実行使用メモリ | 56,824 KB | 
| 最終ジャッジ日時 | 2024-10-02 12:38:48 | 
| 合計ジャッジ時間 | 7,533 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 WA * 14 | 
ソースコード
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);
  }
}
            
            
            
        
            
takeya_okino