結果

問題 No.185 和風
ユーザー codershifthcodershifth
提出日時 2015-07-13 00:24:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,009 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 150,084 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 14:37:16
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

template <typename T>
void make_unique(std::vector<T> &vec) {
        std::sort(vec.begin(), vec.end());
        vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

using namespace std;

class JapaneseStyle {
public:
    void solve(void) {
            int N;
            cin>>N;
            vector<int> ans;
            REP(i, N)
            {
                int x,y;
                cin>>x>>y;
                ans.push_back(y-x);
            }
            make_unique(ans);
            if (ans.size()==1 && ans[0] > 0)
                cout<<ans[0]<<endl;
            else
                cout<<-1<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new JapaneseStyle();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0