結果

問題 No.602 隠されていたゲーム2
ユーザー FF256grhyFF256grhy
提出日時 2017-12-02 00:49:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,375 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 174,164 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 00:27:10
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> T mod(T x, T y) { return (x % y + y) % y; }

LL n, d[100002], x, y, z;
vector<LL> v[2];

LL solve() {
	if(z == 0) { return 0; }
	inc(i, n) { if(z == d[i]) { return 1; } }
	
	d[n] = 0;
	n++;
	d[n] = -10000000000001LL;
	n++;
	
	inc(i, n) { v[mod(d[i], 2LL)].PB(d[i]); }
	inc(i, 2) { sort(RALL(v[i])); }
	
	if(z % 2 == 0) {
		if(z <= v[0][0] * 2 || z <= v[1][0] * 2) { return 2; }
	} else {
		inc(i, v[0].size()) {
			LL ma = max(v[1][0], v[0][i]);
			LL mi = min(v[1][0], v[0][i]);
			if(inII(z, ma - mi, ma + mi)) { return 2; }
		}
		inc(i, v[1].size()) {
			LL ma = max(v[0][0], v[1][i]);
			LL mi = min(v[0][0], v[1][i]);
			if(inII(z, ma - mi, ma + mi)) { return 2; }
		}
	}
	
	return -1;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> d[i]; }
	cin >> x >> y;
	
	z = abs(x) + abs(y);
	
	cout << solve() << endl;
	
	return 0;
}
0