結果

問題 No.185 和風
ユーザー penguinshunyapenguinshunya
提出日時 2019-05-19 14:27:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 403 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 200,284 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 07:54:29
合計ジャッジ時間 2,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:25:11: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
   25 |   cout << x << endl;
      |           ^
main.cpp:8:7: note: 'x' was declared here
    8 |   int x;
      |       ^

ソースコード

diff #

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int x;
  for (int i = 0; i < N; i++) {
    int X, Y;
    cin >> X >> Y;
    if (i == 0) {
      x = Y - X;
      if (x <= 0) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      if (x != Y - X) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << x << endl;
  return 0;
}
0