結果

問題 No.185 和風
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-07-30 18:21:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 101,676 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-17 16:11:57
合計ジャッジ時間 1,880 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:40:22: 警告: ‘n’ is used uninitialized [-Wuninitialized]
   40 |         for(int i=0;i<n;i++){
      |                     ~^~
main.cpp:38:13: 備考: ‘n’ はここで定義されています
   38 |         int n;
      |             ^

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}




int main(void){
	int n;
	set<int>s;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		s.insert(y-x);
	}
	if(s.size()>1)cout<<-1<<endl;
	else{
		for(auto itr = s.begin();itr!=s.end();++itr){
			int now = (*itr);
			if(now<=0)cout<<-1<<endl;
			else cout<<now<<endl;
			return 0;
		}
	}
	return 0;
}
0