結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-16 20:18:17 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 582 bytes | 
| コンパイル時間 | 2,582 ms | 
| コンパイル使用メモリ | 194,500 KB | 
| 最終ジャッジ日時 | 2025-01-14 15:17:45 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 WA * 2 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;
using ll = long long;
ll N, sum = 0, mx = 0;
vector<ll> a, b, c;
void input() {
  cin >> N;
  a.resize(N);
  b.resize(N);
  c.resize(N);
  rep(i, 0, N) {
    cin >> a[i] >> b[i];
    c[i] = a[i] + b[i] * 4;
    sum += c[i];
    mx = max(mx, c[i]);
  }
}
void solve() {
  ll ans = 0;
  if (sum & 1)
    ans = -1;
  else
    rep(i, 0, N) ans += (mx - c[i]) / 2;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  getchar();
}