結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-27 18:48:57 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 412 bytes | 
| コンパイル時間 | 1,578 ms | 
| コンパイル使用メモリ | 168,280 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-05 19:09:27 | 
| 合計ジャッジ時間 | 2,333 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
int main(){
	int n; cin>>n;
	int a,b; int mx=0;
	vector<int> v;
	rep(i,n){
		cin>>a>>b;
		mx=max(mx,(a+b*4));
		v.push_back(a+b*4);
	}
 // for(auto x:v) cout<<x<<endl;
	ll ans=0;
	for(int i=0; i<n; i++){
      if((mx-v[i])%2!=0) {cout<<"-1"<<endl; return 0;}
		ans+=(mx-v[i]);
	}
	cout<<ans/2<<endl;
}