結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Lay_ec
                         | 
                    
| 提出日時 | 2015-04-05 23:24:42 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 599 bytes | 
| コンパイル時間 | 713 ms | 
| コンパイル使用メモリ | 84,328 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-04 02:09:02 | 
| 合計ジャッジ時間 | 1,616 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<long long> len(n);
	for(int i=0;i<n;i++){
		long long a,b;
		cin>>a>>b;
		len[i]=a+4*b;
	}
	sort(len.begin(),len.end());
	long long res=0;
	for(int i=0;i<n-1;i++){
		if((len[n-1]-len[i])%2){cout<<-1<<endl; return 0;}
		res+=(len[n-1]-len[i])/2;
	}
	cout<<res<<endl;
	return 0;
}
            
            
            
        
            
Lay_ec