結果

問題 No.505 カードの数式2
ユーザー HAHAHAHAHAHA
提出日時 2017-04-30 17:19:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 493 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 175,712 KB
実行使用メモリ 440,040 KB
最終ジャッジ日時 2023-10-25 06:45:17
合計ジャッジ時間 8,779 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,344 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 11 ms
5,340 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 892 ms
108,680 KB
testcase_23 AC 83 ms
16,672 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 705 ms
89,680 KB
testcase_27 AC 776 ms
90,272 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(){
	int n;
	cin >> n;
	vector<long long> v(n);
	for(int i=0; i<n; i++) cin >> v[i];
	set<long long> se;
	se.insert(v[0]);
	for(int i=1; i<n; i++) {
		set<long long> se2(se);
		bool ok = (v[i] != 0);
		for(long long x : se2) {
			se.insert(x * v[i]);
			se.insert(x + v[i]);
			se.insert(x - v[i]);
			if(ok) se.insert(x / v[i]);
		}
	}
	
	long long ans = -1e9;
	for(long long x : se) ans = max(ans, x);
	cout << ans << endl;
	return 0;
}
0