結果

問題 No.185 和風
ユーザー TatamoTatamo
提出日時 2016-10-06 23:43:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 849 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 56,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 01:06:04
合計ジャッジ時間 1,193 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:10: warning: ‘result’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << result << endl;
          ^~~~~~

ソースコード

diff #

#include<iostream>
#include<utility>
#include<vector>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

int main(){
	int n;
	cin >> n;
	int result;
	for(int i=0; i<n; i++){
		int x,y;
		cin >> x >> y;
		int tmp = y-x;
		if(i==0) result = tmp;
		if(tmp <= 0 || result != tmp) goto FAILED;
	}

	cout << result << endl;
	return 0;
FAILED:
	cout << -1 << endl;
	return 0;
}
0