結果

問題 No.602 隠されていたゲーム2
ユーザー Pachicobue
提出日時 2017-12-02 01:49:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,658 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 199,440 KB
最終ジャッジ日時 2025-01-05 04:40:31
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 64;

int main()
{
    int N;
    cin >> N;
    vector<ll> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    ll x, y;
    cin >> x >> y;
    const ll dist = abs(x) + abs(y);
    const ll maxi = *max_element(d.begin(), d.end());
    if (dist == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (d[i] == dist) {
            cout << 1 << endl;
            return 0;
        }
    }
    if (dist > maxi * 2) {
        cout << -1 << endl;
        return 0;
    }
    if (dist % 2 == 0) {
        cout << 2 << endl;
    } else {
        for (int i = 0; i < N; i++) {
            if (d[i] % 2 == 1) {
                if (upper_bound(d.begin(), d.end(), dist + d[i]) - lower_bound(d.begin(), d.end(), max(d[i], dist - d[i])) > 0) {
                    cout << 2 << endl;
                    return 0;
                }
            } else {
                continue;
            }
        }
        cout << -1 << endl;
    }


    return 0;
}
0