結果

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

ソースコード

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 = 2 + (s.find(z) == s.end());
		}
	}
	cout << ans << endl;
	return 0;
}
0