結果

問題 No.185 和風
ユーザー Rp7rfRp7rf
提出日時 2015-04-19 23:50:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 963 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 72,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 01:53:35
合計ジャッジ時間 1,201 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  cin>>n;
  vector<ll> x(n);
  vector<ll> y(n);
  bool res = true;
  ll num;
  cin>>x[0]>>y[0];
  if(x[0] >= y[0])res = false;
  num = y[0] - x[0];
  loop(i,1,n){
    cin>>x[i]>>y[i];
    //    cout<<y[i] - x[i] << " == " << num<<endl; 
    if(x[i] >= y[i] || !res || y[i] - x[i] != num){
      res = false;
      break;
    }
  }

  if(res){
    cout<<num<<endl;
  }else{
    cout<<-1<<endl;
  }
}
0