結果

問題 No.602 隠されていたゲーム2
ユーザー kyunakyuna
提出日時 2019-08-31 22:51:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 76,668 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-17 01:04:27
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,388 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 36 ms
4,380 KB
testcase_19 AC 45 ms
4,380 KB
testcase_20 AC 38 ms
4,380 KB
testcase_21 AC 29 ms
4,380 KB
testcase_22 AC 46 ms
4,384 KB
testcase_23 AC 39 ms
4,380 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(dist - d[i]) <= ma[abs(dist - d[i]) % 2]) res = min(res, 2);
    }
    if (res == 3) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}
0