結果
| 問題 | No.602 隠されていたゲーム2 | 
| コンテスト | |
| ユーザー |  chocorusk | 
| 提出日時 | 2019-07-07 19:17:22 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,416 bytes | 
| コンパイル時間 | 810 ms | 
| コンパイル使用メモリ | 103,796 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-05 06:00:48 | 
| 合計ジャッジ時間 | 2,360 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 RE * 1 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
    int n; ll x, y;
    cin>>n;
    ll d[100010];
    vector<ll> d0, d1;
    for(int i=0; i<n; i++){
        cin>>d[i];
        if(d[i]&1) d1.push_back(d[i]);
        else d0.push_back(d[i]);
    }
    cin>>x>>y;
    ll s=abs(x)+abs(y);
    if(s==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0; i<n; i++){
        if(s==d[i]){
            cout<<1<<endl;
            return 0;
        }
    }
    sort(d0.begin(), d0.end());
    sort(d1.begin(), d1.end());
    if(s%2==0){
        if(s<=2*max(d0.back(), d1.back())) cout<<2<<endl;
        else cout<<-1<<endl;
    }else{
        if(d0.empty() || d1.empty()){
            cout<<-1<<endl;
            return 0;
        }
        for(auto a:d0){
            int i=lower_bound(d1.begin(), d1.end(), abs(a-s))-d1.begin();
            if(i<d1.size() && d1[i]<=a+s){
                cout<<2<<endl;
                return 0;
            }
        }
        cout<<-1<<endl;
    }
    return 0;
}
            
            
            
        