結果

問題 No.602 隠されていたゲーム2
ユーザー pinpin
提出日時 2017-12-02 16:44:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,376 bytes
コンパイル時間 1,248 ms
コンパイル使用メモリ 86,016 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-18 20:00:51
合計ジャッジ時間 3,298 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int n;
ll x, y, d[100005];
int main(void){
    cin >> n;
    ll even[2], odd[2];
    for (int i = 0; i < 2; i++){
        even[i] = odd[i] = -10000000005;
    }

    for (int i = 0; i < n; i++) cin >> d[i];

    sort(d, d + n);
    for (int i = n - 1; i >= 0; i--){
        if (d[i] % 2 == 0){
            for (int j = 0; j < 2; j++){
                if (even[j] < 0){
                    even[j] = d[i];
                    break;
                }
            }
        }
        else{
            for (int j = 0; j < 2; j++){
                if (odd[j] < 0){
                    odd[j] = d[i];
                    break;
                }
            }
        }
    }
    cin >> x >> y;

    ll D = max(x, -x) + max(y, -y);

    for (int i = 0; i < n; i++){
        if (D == d[i]){
            cout << 1 << endl;
            return 0;
        }
    }

    if (((D + even[0] + even[1]) % 2 == 0 && even[0] + even[1] >= D) ||
        ((D + odd[0] + odd[1]) % 2 == 0 && odd[0] + odd[1] >= D) ||
        ((D + even[0] + odd[0]) % 2 == 0 && even[0] + odd[0] >= D)){

        cout << 2 << endl;
        return 0;
    }

    cout << -1 << endl;

}
0