結果

問題 No.178 美しいWhitespace (1)
ユーザー snrnsidy
提出日時 2021-04-28 01:07:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 127,072 KB
最終ジャッジ日時 2025-01-21 01:32:35
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>
#include <random>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, a, b;
	vector <int> v;
	int MAX = 0;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		v.push_back(a + 4 * b);
		MAX = max(MAX, v[i]);
	}

	long long int res = 0;

	for (int i = 0; i < n; i++)
	{
		long long int d = abs(v[i] - MAX);
		if (d % 2 == 1)
		{
			cout << -1 << '\n';
			return 0;
		}
		res += (d / 2);
	}

	cout << res << '\n';


	return 0;
}
0