結果

問題 No.324 落ちてた閉路グラフ
ユーザー kimiyukikimiyuki
提出日時 2016-02-29 11:42:35
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,023 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 66,532 KB
実行使用メモリ 487,224 KB
最終ジャッジ日時 2023-10-24 19:08:13
合計ジャッジ時間 12,121 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 594 ms
193,052 KB
testcase_05 AC 1,629 ms
487,224 KB
testcase_06 AC 513 ms
157,104 KB
testcase_07 AC 1,418 ms
445,196 KB
testcase_08 AC 562 ms
168,748 KB
testcase_09 AC 225 ms
71,848 KB
testcase_10 AC 549 ms
168,748 KB
testcase_11 AC 225 ms
71,848 KB
testcase_12 RE -
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 96 ms
40,388 KB
testcase_15 AC 184 ms
73,636 KB
testcase_16 RE -
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 RE -
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 RE -
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 RE -
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 1,539 ms
471,336 KB
testcase_33 AC 1,252 ms
392,124 KB
testcase_34 AC 549 ms
170,336 KB
testcase_35 AC 4 ms
4,628 KB
testcase_36 AC 97 ms
40,860 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
template <class T> bool setmax(T & l, T const & r) { if (not (l < r)) return false; l = r; return true; }
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
const int INF = 1e9;
int main() {
    int n, m; cin >> n >> m;
    vector<int> w(n); repeat (i,n) cin >> w[i];
    int ans = - INF;
    repeat (p,2) {
        vvvi dp(n+1, vvi(m+1, vi(2, - INF)));
        dp[0][p][p] = 0;
        repeat (i,n-1) repeat (j,m+1) {
            ;;;;;;;;;;; dp[i+1][j][false] = max(dp[i][j  ][false], dp[i][j  ][true]);
            if (j >= 1) dp[i+1][j][ true] = max(dp[i][j-1][false], dp[i][j-1][true] + w[i]);
        }
        repeat (j,m+1) {
            dp[n][j][false] = max(dp[n-1][j][false], dp[n-1][j][true]);
            dp[n][j][ true] = max(dp[n-1][j][false], dp[n-1][j][true] + (p ? w[n-1] : 0));
        }
        setmax(ans, dp[n][m][p]);
    }
    cout << ans << endl;
    return 0;
}
0