結果

問題 No.178 美しいWhitespace (1)
ユーザー ldsyb
提出日時 2016-05-10 08:20:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 65,504 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 00:32:19
合計ジャッジ時間 1,441 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
	long long ans = 0,n,count = 0;
	cin >> n;
	long long a[n],b[n];
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
		count = max(count,a[i] + 4 * b[i]);
	}
	for(int i = 0;i < n;i++){
		if(count - (a[i] + 4 * b[i]) & 1){
			cout << -1 << endl;
			return 0;
		}
		ans += (count - (a[i] + 4 * b[i])) / 2;
	}
	cout << ans << endl;
}
0