結果
問題 | No.185 和風 |
ユーザー |
|
提出日時 | 2019-12-23 03:40:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 440 bytes |
コンパイル時間 | 833 ms |
コンパイル使用メモリ | 75,524 KB |
最終ジャッジ日時 | 2025-01-08 14:06:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; typedef long long int ll; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; int ans=-1; for(int i=0;i<n;i++){ int x,y ;cin >> x >> y; if(x==y){ cout << -1 << endl; return 0; } if(y-x>0&&(ans==-1||ans==y-x)){ ans=y-x; } else{ cout << -1 << endl; return 0; } } cout << ans << endl; }