結果

問題 No.602 隠されていたゲーム2
ユーザー kyunakyuna
提出日時 2019-08-31 22:46:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 75,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 21:09:18
合計ジャッジ時間 2,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int &di: d) cin >> di;
    sort(d.begin(), d.end());
    int x, y; cin >> x >> y;
    int dist = abs(x) + abs(y);
    int res = dist == 0 ? 0 : 3;
    vector<int> ma{0, 0};
    for (int i = 0; i < n; i++) {
        if (d[i] == dist) res = min(res, 1);
        ma[d[i] % 2] = d[i];
        if (abs(x - d[i]) <= ma[abs(x - d[i]) % 2]) res = min(res, 2);
    }
    if (res == 3) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}
0