結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-21 23:56:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 433 bytes |
| コンパイル時間 | 502 ms |
| コンパイル使用メモリ | 61,544 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 06:09:50 |
| 合計ジャッジ時間 | 1,765 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 3 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long N;
long DFS(long x, const vector<long> &a, long i) {
if (i == N) {
return x;
}
return max(max(DFS(x + a[i], a, i + 1), DFS(x * a[i], a, i + 1)),
DFS(x - a[i], a, i + 1));
}
int main() {
cin >> N;
vector<long> a(N);
for (long i = 0; i < N; i++) {
cin >> a[i];
}
cout << DFS(a[0], a, 1) << endl;;
return 0;
}