結果

問題 No.185 和風
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-08 22:45:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 290 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 63,872 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 03:48:15
合計ジャッジ時間 1,003 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
const int INF = 1e9;

int main()
{
	int n;
	cin >> n;

	int ans;
	rep(i, n)
	{
		int x, y;
		cin >> x >> y;

		int z = y - x;
		ans = ((i == 0 && z > 0) || ans == z) ? z : -1;
	}
	cout << ans << endl;
}
0