結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー masamasa
提出日時 2017-04-21 22:40:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 70,852 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 11:25:44
合計ジャッジ時間 5,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

const long long inf = 1e18;

int main() {
	int n;
	cin >> n;

	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int limit = 1;
	for (int i = 0; i < n - 1; i++) {
		limit *= 3;
	}

	long long ans = -inf;
	for (int i = 0; i < limit; i++) {
		int tmp = i;
		long long x = a[0];
		for (int j = 1; j < n; j++) {
			int op = tmp % 3;

			switch (op) {
				case 0: x += a[j]; break;
				case 1: x -= a[j]; break;
				case 2: x *= a[j]; break;
				default: break;
			}

			tmp /= 3;
		}

		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}
0