結果
問題 | No.185 和風 |
ユーザー |
|
提出日時 | 2015-04-19 23:22:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 507 ms |
コンパイル使用メモリ | 58,788 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 18:17:28 |
合計ジャッジ時間 | 1,028 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:30:17: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] 30 | cout << ans << endl; | ^~~
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>using namespace std;int main() {int n, x, y;int ans;cin >> n;for (int i = 0; i < n; i++) {cin >> x >> y;if (i == 0) {ans = y - x;if (ans <= 0) {cout << -1 << endl;return 0;}}if (ans != y - x) {cout << -1 << endl;return 0;}}cout << ans << endl;return 0;}