結果

問題 No.602 隠されていたゲーム2
ユーザー PachicobuePachicobue
提出日時 2017-12-02 02:14:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,207 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 202,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 00:43:44
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 32 ms
5,376 KB
testcase_21 AC 30 ms
5,376 KB
testcase_22 AC 40 ms
5,376 KB
testcase_23 AC 39 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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];
    }
    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 or dist % 2 == 1) {
        cout << -1 << endl;
    } else {
        cout << 2 << endl;
    }
    return 0;
}
0