結果

問題 No.505 カードの数式2
ユーザー finefine
提出日時 2017-04-21 23:13:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 522 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 175,760 KB
実行使用メモリ 108,628 KB
最終ジャッジ日時 2023-10-25 06:44:57
合計ジャッジ時間 8,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 10 ms
5,288 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 886 ms
108,628 KB
testcase_23 AC 82 ms
16,620 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 700 ms
89,628 KB
testcase_27 AC 763 ms
90,220 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	set<ll> b;
	b.insert(a[0]);
	for (int i = 1; i < n; i++) {
		set<ll> c(b);
		bool flag = (a[i] != 0);
		for (ll x : c) {
			b.insert(x * a[i]);
			b.insert(x + a[i]);
			b.insert(x - a[i]);
			if (flag) b.insert(x / a[i]);
		}
	}
	ll ans = -1e9;
	for (ll x : b) ans = max(ans, x);
	cout << ans << endl;
	return 0;
}
0