結果

問題 No.602 隠されていたゲーム2
コンテスト
ユーザー hiroakie
提出日時 2017-12-18 15:47:06
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 403 ms
コンパイル使用メモリ 91,364 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2026-05-26 06:30:58
合計ジャッジ時間 5,003 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long int ll;
const ll N = 100000;
ll d[N],n,cp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)scanf("%d", d + i);
	sort(d , d + n);
	ll x, y; cin >> x >> y;
	cp = abs(x) + abs(y);
	if (cp == 0) { cout << 0 << endl; goto end; }
	if (find(d, d + n, cp) - d < n) { cout << 1 << endl; goto end; }
	for (int i = 0; i < n; i++) {
		ll lb = abs(cp - d[i]), ub = (cp + d[i]);
		for (int j = lower_bound(d, d + n, lb) - d; j<n&&d[j] <= ub; j++) {
			if (d[j] % 2 == ub % 2) { cout << 2 << endl; goto end; }
		}
	}
	cout << -1 << endl;
end:;
	return 0;
}
0