結果

問題 No.505 カードの数式2
ユーザー amtgjwamtgjw
提出日時 2018-06-04 17:29:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 65,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 22:12:00
合計ジャッジ時間 9,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 685 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 682 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 683 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MINF		-200000007
#define MOD			1048576 	
// 2^20

#define MAX 		1000005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

//int dp[MAX];

int N;
vector<int> a(16);

ll bfs(ll sum,int n){
	if(n-1==N){
		return max(sum+a[n],max(sum-a[n],sum*a[n]));
	}
	else
		return max(bfs(sum+a[n],n+1),max(bfs(sum-a[n],n+1),bfs(sum*a[n],n+1)));
}

int main(){
	cin>>N;
	REP(i,N)cin>>a[i];

	cout << bfs(0LL,0) << endl;

	return 0;
}
0