結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  | 
                    
| 提出日時 | 2019-09-17 23:38:38 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 496 bytes | 
| コンパイル時間 | 624 ms | 
| コンパイル使用メモリ | 74,924 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-07 13:54:27 | 
| 合計ジャッジ時間 | 1,671 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> z;
    for(int i = 0; n > i; i++){
        int a,b;cin>>a>>b;
        z.push_back(a+b*4);
    }
    sort(z.begin(),z.end(),greater<int>());
    long long ans = 0;
    for(int i = 1; n > i; i++){
        if((z[0]-z[i])%2==1){
            cout << -1 << endl;
            return 0;
        }else{
            ans += (z[0]-z[i])/2;
        }
    }
    cout << ans << endl;
}