結果

問題 No.505 カードの数式2
ユーザー olphe
提出日時 2017-04-21 22:26:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 792 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 109,284 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-07-20 05:21:38
合計ジャッジ時間 4,358 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N;
int num[16];
long long int ans = LLONG_MIN;

void Search(int n, long long int box,int end) {
	if (n == end) {
		ans = max(ans, box);
		return;
	}
	Search(n + 1, box + num[n + 1], end);
	Search(n + 1, box - num[n + 1], end);
	Search(n + 1, box * num[n + 1], end);
	if(num[n+1])Search(n + 1, box + num[n + 1], end);
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> num[i];
	Search(0, num[0], N - 1);
	cout << ans << endl;
	return 0;
}
0