結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             dnish
                         | 
                    
| 提出日時 | 2017-07-03 22:03:33 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 408 bytes | 
| コンパイル時間 | 1,381 ms | 
| コンパイル使用メモリ | 167,704 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-05 12:44:26 | 
| 合計ジャッジ時間 | 2,329 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
int main(){
	int N;
	cin>>N;
	ll a[1010],b[1010];
	ll mx=0;
	REP(i,0,N){
		cin>>a[i]>>b[i];
		mx=max(mx,a[i]+4*b[i]);
	}
	ll ans=0;
	REP(i,0,N){
		int now=a[i]+4*b[i];
		if((mx-now)%2==0) ans+=(mx-now)/2;
		else{
			ans=-1;
			break;
		}
	}
	p(ans);
	return 0;
}
            
            
            
        
            
dnish