結果

問題 No.602 隠されていたゲーム2
ユーザー hiroakiehiroakie
提出日時 2017-12-18 15:47:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 662 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 67,792 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-22 05:41:12
合計ジャッジ時間 4,827 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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