結果

問題 No.185 和風
ユーザー dorakazu8134dorakazu8134
提出日時 2015-04-20 00:00:07
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 523 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 66,832 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 02:10:28
合計ジャッジ時間 1,320 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	vector<long long>p;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		if (y - x >= 0){
			p.push_back(y - x);
		}
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < p.size()-1; i++){
		if (p[i] == p[i + 1]){
			int c=0;
			for (int i2 = i+1; i2 < i + n; i2++){
				if (p[i] == p[i2]){
					c++;
				}
			}
			if (c == n - 1){
				cout << p[i] << endl;
				return 0;
			}
		}
	}
	cout << "-1" << endl;
}
0