結果

問題 No.602 隠されていたゲーム2
ユーザー pinpin
提出日時 2017-12-02 06:54:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,397 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 83,836 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-18 16:07:30
合計ジャッジ時間 2,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 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 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 31 ms
4,376 KB
testcase_19 AC 38 ms
4,392 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 38 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;

ll n, 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] = -1000;
    }

    for (int i = 0; i < n; i++){
        cin >> d[i];
        if (d[i] % 2 == 0 && even[0] < d[i]){
            even[1] = even[0];
            even[0] = d[i];
            continue;
        }

        if (d[i] % 2 == 0 && even[1] < d[i]) even[1] = d[i];

        if (d[i] % 2 == 1 && odd[0] < d[i]){
            odd[1] = odd[0];
            odd[0] = d[i];
            continue;
        }

        if (d[i] % 2 == 1 && odd[1] < d[i]) odd[1] = d[i];

    }

    cin >> x >> y;

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

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

    
    if ((even[0] > 0 && even[1]>0 && (D + even[0] + even[1]) % 2 == 0 && even[0] + even[1] >= D) ||
        (odd[0]>0 && odd[1]>0 && (D + odd[0] + odd[1]) % 2 == 0 && odd[0] + odd[1] >= D) ||
        (even[0] > 0 && odd[0] > 0 && (D + even[0] + odd[0]) % 2 == 0 && even[0] + odd[0] >= D)){
        cout << 2 << endl;
        return 0;
     }

    cout << -1 << endl;

}
0