結果

問題 No.602 隠されていたゲーム2
ユーザー creep04
提出日時 2017-12-02 03:08:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 160,472 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 02:32:48
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n, x, y, a, t, r=-1;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	int d[n];
	for (int i = 0; i < n; ++i) cin >> d[i];
	sort(d, d+n);
	cin >> x >> y;
	a = abs(x) + abs(y);
	if (a==0) {
		cout << 0 << "\n";
		return 0;
	}
	
	for (int i = 0; i < n; ++i) {
		if (d[i]==a) r = 1;
		else if (binary_search(d+i+1, d+n, abs(a-d[i])) || binary_search(d+i+1, d+n, a+d[i]))
			r = 2;
		if (r!=-1) break;
	}
	cout << r << "\n";
}
0