結果

問題 No.602 隠されていたゲーム2
ユーザー pinpin
提出日時 2017-12-02 17:41:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,414 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 85,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 20:04:21
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 38 ms
4,380 KB
testcase_19 AC 45 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 40 ms
4,380 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 a[4];
    for (int i = 0; i < 4; i++) a[i] = -1000000005;

    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 (a[j] < 0){
                    a[j] = d[i];
                    break;
                }
            }
        }
        else{
            for (int j = 2; j < 4; j++){
                if (a[j] < 0){
                    a[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;
        }
    }

    for (int i = 0; i < 4; i++){
        for (int j = i + 1; j < 4; j++){
            if ((D + a[i] + a[j]) % 2 == 0 && a[i] + a[j] >= D){
                if (a[i] == 1 || a[j] == 1){
                    if (a[i] + a[j] != D + 1)continue;
                }
                cout << 2 << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

}
0