結果

問題 No.178 美しいWhitespace (1)
ユーザー masa
提出日時 2015-04-05 23:29:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 61,932 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 02:10:51
合計ジャッジ時間 1,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int n, a, b;

	cin >> n;
	int max_w = 0;
	vector<int> w(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		w[i] = a + b * 4;
		max_w = max(max_w, w[i]);
	}

	long long ans = 0;
	long long diff;
	for (int i = 0; i < n; i++) {
		diff = max_w - w[i];
		if (diff % 2 == 1) {
			cout << -1 << endl;
			return 0;
		}
		ans += diff / 2;
	}

	cout << ans << endl;
	return 0;
}
0