結果
| 問題 | 
                            No.602 隠されていたゲーム2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-12-02 05:59:35 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 825 bytes | 
| コンパイル時間 | 584 ms | 
| コンパイル使用メモリ | 73,424 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-27 22:07:07 | 
| 合計ジャッジ時間 | 1,567 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 WA * 5 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    long move_mass[n];
    long parity_max[2] = {0, 0};
    for(int i = 0; i < n; i++){
        cin >> move_mass[i];
        parity_max[move_mass[i] % 2] = max(parity_max[move_mass[i] % 2], move_mass[i]);
    }
    long x, y;
    cin >> x >> y;
    if(!x && !y){
        cout << 0 << endl;
    }
    sort(move_mass, move_mass + n);
    for(int i = 0; i < n; i++){
        if(move_mass[i] == abs(x) + abs(y)){
            cout << 1 << endl;
            return 0;
        }
    }
    if(((abs(x) + abs(y)) % 2 == 0 && max(parity_max[0], parity_max[1]) * 2 >= abs(x) + abs(y)) || parity_max[0] + parity_max[1] >= (abs(x) + abs(y))){
        cout << 2 << endl;
        return 0;
    }
    cout << -1 << endl;
}