結果
| 問題 | No.602 隠されていたゲーム2 | 
| コンテスト | |
| ユーザー |  creep04 | 
| 提出日時 | 2017-12-02 03:54:56 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 577 bytes | 
| コンパイル時間 | 1,530 ms | 
| コンパイル使用メモリ | 163,560 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-28 02:35:54 | 
| 合計ジャッジ時間 | 2,964 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 WA * 7 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n, x, y, t, r=3;
long long a;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	vector<long long> d(n);
	for (int i = 0; i < n; ++i) cin >> d[i];
	sort(d.begin(), d.end());
	cin >> x >> y;
	a = abs(x) + abs(y);
	if (a==0) {
		printf("0\n");
		return 0;
	}
	
	for (int i = 0; i < n; ++i) {
		if (d[i]==a) r = 1;
		else if (i<n-1 && (binary_search(d.begin()+i+1, d.end(), abs(a-d[i]))
						   || binary_search(d.begin()+i+1, d.end(), a+d[i])))
			if (r==3) r = 2;
	}
	if (r==3) r = -1;
	cout << r << "\n";
}
            
            
            
        