結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             t8m8⛄️
                         | 
                    
| 提出日時 | 2015-04-05 23:35:47 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 221 ms / 2,000 ms | 
| コード長 | 1,088 bytes | 
| コンパイル時間 | 3,695 ms | 
| コンパイル使用メモリ | 78,320 KB | 
| 実行使用メモリ | 57,024 KB | 
| 最終ジャッジ日時 | 2024-07-04 02:12:48 | 
| 合計ジャッジ時間 | 9,987 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class No178 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);
    static void solve() {
        int n = in.nextInt();
        long[] a = new long[n];
        long max = 0;
        for (int i=0; i<n; i++) {
            a[i] = in.nextInt()+in.nextInt()*4;
            max = max(max,a[i]);
        }
        
        long cnt = 0;
        for (int i=0; i<n; i++) {
            if ((max - a[i]) %2 == 1) {
                out.println("-1");
                return ;
            }
            cnt += (max - a[i])/2;
        }
        out.println(cnt);
    }
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        solve();
        out.flush();
        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }
    static void trace(Object... o) { System.out.println(deepToString(o));}
}
            
            
            
        
            
t8m8⛄️