結果

問題 No.602 隠されていたゲーム2
ユーザー Lepton_sLepton_s
提出日時 2017-12-02 00:43:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,914 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 104,816 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-05-06 00:25:54
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 50 ms
10,368 KB
testcase_22 RE -
testcase_23 AC 62 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
map<ll, int> dc;
int main(){
	int n;
	cin>>n;
	vector<ll> x(n);
	rep(i, n) cin>>x[i];
	sort(all(x));
	ll a, b;
	cin>>a>>b;
	a = abs(a); b = abs(b);
	ll c = abs(a)+abs(b);
	if(c==0){
		cout<<0<<endl;
		return 0;
	}
	rep(i, n){
		if(c==x[i]){
			cout<<1<<endl;
			return 0;
		}
		dc[x[i]] = 1;
	}
	ll mn1 = 1e10, mx1 = -1e10;
	ll mn2 = 1e10, mx2 = -1e10;
	rep(i, n){
		if((x[i]+c)%2){
			mn1 = min(mn1, abs(x[i]-c));
			mx1 = max(mx1, x[i]+c);
		} else {
			mn2 = min(mn2, abs(x[i]-c));
			mx2 = max(mx2, x[i]+c);
		}
	}
	bool ok = false;
	rep(i, n){
		if(x[i]%2){
			if(mn1<=x[i] && x[i]<=mx1) ok = true;
		} else {
			if(mn2<=x[i] && x[i]<=mx2) ok = true;
		}
	}
	cerr<<mn1<<" "<<mx1<<" "<<mn2<<" "<<mx2<<endl;
	if(ok) return -1;
	if(ok) cout<<2<<endl;
	else {
		cout<<-1<<endl;
	}
	return 0;
}
0