結果

問題 No.185 和風
ユーザー mine691mine691
提出日時 2018-09-30 00:11:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 272 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 64,524 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 13:26:24
合計ジャッジ時間 1,046 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;

int main() {
	int n, ans;
	cin >> n;
	for (int i = 0;i < n;i++) {
		int a, b;
		cin >> a >> b;
		if (i == 0)ans = b - a;
		else if (ans != b - a) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << (ans > 0 ? ans : -1) << endl;
}
0