結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-06 23:43:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 849 bytes |
| コンパイル時間 | 497 ms |
| コンパイル使用メモリ | 56,796 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 19:00:40 |
| 合計ジャッジ時間 | 1,057 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:17: warning: ‘result’ may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | cout << result << endl;
| ^~~~~~
ソースコード
#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;
}