結果

問題 No.505 カードの数式2
ユーザー aaaaaa
提出日時 2018-11-16 20:46:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,169 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 99,488 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 01:30:41
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main() {
	int i, j;
	int n;
	vector<long long >a;
	vector<vector<long long>>dp(1000, vector<long long>(4, 0));


	cin >> n;

	for (i = 0; i < n; i++) {
		long long num;
		cin >> num;
		a.push_back(num);
	}

	dp[0][0] = a[0]; dp[0][1] = a[0]; dp[0][2] = a[0]; dp[0][3] = a[0];



	for (i = 1; i < n; i++) {
		
		dp[i][0] = max({ dp[i - 1][0], dp[i - 1][1], dp[i - 1][2], dp[i - 1][3] }) + a[i];
		dp[i][1] = max({ dp[i - 1][0], dp[i - 1][1], dp[i - 1][2], dp[i - 1][3] }) - a[i];
		dp[i][2] = max({ dp[i - 1][0], dp[i - 1][1], dp[i - 1][2], dp[i - 1][3] }) * a[i];
		
		if (a[i] != 0) {
			dp[i][3] = max({ dp[i - 1][0], dp[i - 1][1], dp[i - 1][2], dp[i - 1][3] }) / a[i];
		}

	}


	cout << max({ dp[n - 1][0], dp[n - 1][1], dp[n - 1][2], dp[n - 1][3] }) << endl;











	getchar();
	getchar();
	return 0;
}
0