結果

問題 No.467 隠されていたゲーム
ユーザー hotpepsihotpepsi
提出日時 2016-12-22 01:41:31
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 72,320 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 14:15:19
合計ジャッジ時間 1,389 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 21 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	LL d[16] = {};
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	LL x, y;
	cin >> x >> y;
	LL z = max(abs(x), abs(y));
	sort(d, d + n);
	LL ans = (z + d[n - 1] - 1) / d[n - 1];
	if (ans > 0 && ans < 3) {
		if (find(d, d + n, z) < (d + n)) {
			ans = 1;
		} else {
			set<LL> s;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					s.insert(d[i] + d[j]);
					s.insert(abs(d[i] - d[j]));
				}
			}
			ans += (s.find(z) == s.end());
		}
	}
	cout << ans << endl;
	return 0;
}
0