結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-09 06:19:27 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 650 bytes | 
| コンパイル時間 | 841 ms | 
| コンパイル使用メモリ | 78,456 KB | 
| 最終ジャッジ日時 | 2025-01-09 15:16:35 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using lint = long long;
void solve() {
    int n;
    std::cin >> n;
    std::vector<lint> xs(n);
    for (auto& x : xs) {
        lint a, b;
        std::cin >> a >> b;
        x = a + b * 4;
    }
    std::sort(xs.begin(), xs.end());
    lint max = xs.back(), ans = 0;
    for (auto x : xs) {
        if ((max - x) % 2 != 0) {
            std::cout << -1 << std::endl;
            return;
        }
        ans += (max - x) / 2;
    }
    std::cout << ans << std::endl;
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}