結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-15 00:13:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 308 bytes |
| コンパイル時間 | 1,612 ms |
| コンパイル使用メモリ | 165,448 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-20 01:00:37 |
| 合計ジャッジ時間 | 1,873 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:17:30: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
17 | cout << (ans > 0 ? ans : -1) << endl;
| ^
main.cpp:7:7: note: 'ans' was declared here
7 | int ans;
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int ans;
for (int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
if (i && y - x != ans) {
cout << -1 << endl;
return 0;
}
ans = y - x;
}
cout << (ans > 0 ? ans : -1) << endl;
return 0;
}