結果

問題 No.185 和風
ユーザー test
提出日時 2020-09-06 13:45:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 447 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 193,668 KB
最終ジャッジ日時 2025-01-14 07:44:20
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int solve() {
  int N, a, b, c;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) {
    cin >> a >> b;
    v[i] = b - a;
    if (v[i] < 1) return -1;
  }
  if (N == 1) return v[0];
  rep(i, 0, N - 1) if (v[i] != v[i + 1]) return -1;
  return v[0];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << solve() << endl;
  getchar();
}
0