結果

問題 No.185 和風
ユーザー Goryudyuma
提出日時 2015-04-21 10:49:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 378 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 56,668 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 19:01:44
合計ジャッジ時間 860 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>


using namespace std;

int main()
{
	int N;
	cin >> N;
	int a, b;
	int ans=-10;
	for (size_t i = 0; i < N; i++)
	{
		cin >> a >> b;
		if (ans == -10)
		{
			if (b - a <= 0)
			{
				ans = -1;
			} else
			{
				ans = b - a;
			}
		} else
		{
			if (b - a != ans)
			{
				ans = -1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0