結果

問題 No.505 カードの数式2
ユーザー ei1333333
提出日時 2017-04-21 22:41:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 653 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 158,328 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-07-20 05:32:12
合計ジャッジ時間 4,697 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;


int N, A[16];

int64 createArray(int idx, int sz, int64 val)
{
  if(idx == sz) return (val);
  int64 ret = -INF;
  ret = max(ret, createArray(idx + 1, sz, val + A[idx]));
  ret = max(ret, createArray(idx + 1, sz, val - A[idx]));
  ret = max(ret, createArray(idx + 1, sz, val * A[idx]));
  if(A[idx] != 0) ret = max(ret, createArray(idx + 1, sz, val / A[idx]));
  return (ret);
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cout << createArray(1, N, A[0]) << endl;
}
0