結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
penguinshunya
|
| 提出日時 | 2019-05-19 14:27:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 403 bytes |
| コンパイル時間 | 1,725 ms |
| コンパイル使用メモリ | 191,764 KB |
| 最終ジャッジ日時 | 2025-01-07 03:47:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
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;
| ^
ソースコード
#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;
}
penguinshunya