結果

問題 No.185 和風
ユーザー gotutiyangotutiyan
提出日時 2017-11-21 16:47:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 904 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 89,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 11:49:37
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:55:17: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   55 |         cout << ans << endl;
      |                 ^~~
main.cpp:31:13: 備考: ‘ans’ はここで定義されています
   31 |         int ans;
      |             ^~~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <stdlib.h>
#include <time.h>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long
#define INF 2000000000

using namespace std;
int main() {
	int n;
	bool st = true;
	int ans;
	cin >> n;
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		if (b - a <= 0) {
			cout << -1 << endl;
			return 0;
		}
		else {
			if (st) {
				ans = b - a;
				st = false;
			}
			else {
				if (ans != b - a) {
					cout << -1 << endl;
					return 0;
				}

			}
		}
	}

	cout << ans << endl;
	

	return 0;
}
0