結果

問題 No.185 和風
コンテスト
ユーザー masa
提出日時 2015-04-19 23:22:46
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 416 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 682 ms
コンパイル使用メモリ 75,860 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-26 01:21:48
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   30 |         cout << ans << endl;
      |                 ^~~
main.cpp:11:13: note: 'ans' was declared here
   11 |         int ans;
      |             ^~~

ソースコード

diff #
raw source code

#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;
}
0