結果

問題 No.324 落ちてた閉路グラフ
ユーザー pekempeypekempey
提出日時 2015-12-17 00:13:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 145,996 KB
実行使用メモリ 147,164 KB
最終ジャッジ日時 2023-10-14 11:41:56
合計ジャッジ時間 5,327 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
146,888 KB
testcase_01 AC 60 ms
146,928 KB
testcase_02 AC 58 ms
147,020 KB
testcase_03 AC 61 ms
147,152 KB
testcase_04 AC 85 ms
146,864 KB
testcase_05 AC 129 ms
147,000 KB
testcase_06 WA -
testcase_07 AC 106 ms
146,828 KB
testcase_08 AC 70 ms
146,968 KB
testcase_09 AC 59 ms
146,856 KB
testcase_10 AC 70 ms
146,832 KB
testcase_11 AC 58 ms
146,896 KB
testcase_12 AC 49 ms
147,032 KB
testcase_13 WA -
testcase_14 AC 54 ms
146,976 KB
testcase_15 AC 57 ms
146,916 KB
testcase_16 AC 48 ms
146,816 KB
testcase_17 WA -
testcase_18 AC 48 ms
146,892 KB
testcase_19 AC 48 ms
146,860 KB
testcase_20 AC 48 ms
146,908 KB
testcase_21 AC 48 ms
146,816 KB
testcase_22 AC 48 ms
146,872 KB
testcase_23 AC 48 ms
146,816 KB
testcase_24 AC 48 ms
147,156 KB
testcase_25 AC 48 ms
146,968 KB
testcase_26 AC 48 ms
146,844 KB
testcase_27 WA -
testcase_28 AC 48 ms
146,928 KB
testcase_29 AC 48 ms
146,888 KB
testcase_30 AC 48 ms
146,816 KB
testcase_31 AC 48 ms
146,820 KB
testcase_32 AC 113 ms
146,964 KB
testcase_33 AC 104 ms
147,140 KB
testcase_34 WA -
testcase_35 AC 53 ms
146,920 KB
testcase_36 AC 55 ms
146,952 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using namespace std;
typedef long long ll;

const int inf = 1e9;
int dp[3030][3030][2][2]; // i, num, take prev, take 0

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> w(n);
	rep (i, n) scanf("%d", &w[i]);

	rep (i, 3030) rep (j, 3030) rep (k, 2) rep (l, 2) dp[i][j][k][l] = -inf;
	dp[0][0][0][0] = 0;
	dp[0][1][1][1] = 0;
	rep (i, 1, n) rep (j, m + 1) rep (k, 2) rep (l, 2) {
		chmax(dp[i][j][0][l], dp[i - 1][j][k][l]);
		chmax(dp[i][j + 1][1][l], dp[i - 1][j][k][l] + w[i] * k);
	}
	int ans = -inf;
	rep (k, 2) rep (l, 2) {
		chmax(ans, dp[n - 1][m][k][l] + l * w[0]);
	}
	cout << ans << endl;
	return 0;
}
0