結果

問題 No.185 和風
ユーザー KKT89KKT89
提出日時 2019-12-23 03:40:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 440 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 79,104 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 05:07:45
合計ジャッジ時間 1,400 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int ans=-1;
	for(int i=0;i<n;i++){
		int x,y ;cin >> x >> y;
		if(x==y){
			cout << -1 << endl;
			return 0;
		}
		if(y-x>0&&(ans==-1||ans==y-x)){
			ans=y-x;
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}
0