結果

問題 No.178 美しいWhitespace (1)
ユーザー zaichu
提出日時 2015-12-19 20:27:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 68,028 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 10:47:17
合計ジャッジ時間 1,715 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <algorithm>
#include <set>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> total;
	int a,b;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		int x = a + 4 * b;
		total.push_back(x);
	}
	sort(total.begin(),total.end(),greater<int>());
	int max = total[0];
	int sum = 0;
	for(int i = 1; i < n; i++){
		if((max - total[i]) % 2){
			cout << -1 << endl;
			return 0;
		}
		sum += max-total[i];
	}
	cout << sum / 2 << endl;
	return 0;
}		
0