結果

問題 No.185 和風
ユーザー soragsorag
提出日時 2022-08-15 19:48:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 785 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 81,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 06:37:25
合計ジャッジ時間 1,275 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include<string>
#include<queue>
#include<math.h>
#define all(x) begin(x),end(x)
#define ll long long
#define P pair<int,int>
#define lP pait<ll,ll>
using namespace std;
int main() {
    bool f=0;
    int n,c=0;
    cin>>n;
    vector<P> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        b[i].first=a[i].second-a[i].first;
    }
    
    for(int i=0;i<n;i++){
        if(b[i].first<=0) f=1;
    }
    
    if(f) cout<<-1<<endl;
    
    else{
   
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(b[i].first==b[j].first) b[i].second++;
        }
        if(b[i].second==n) c++;
    }
    if(c==n) cout<<b[1].first<<endl;
    else cout<<-1<<endl;
    }
    return 0;
}
  
    

0