結果

問題 No.324 落ちてた閉路グラフ
ユーザー hogeover30hogeover30
提出日時 2016-04-06 14:49:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 58,200 KB
実行使用メモリ 145,060 KB
最終ジャッジ日時 2024-04-27 16:10:18
合計ジャッジ時間 3,487 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
144,932 KB
testcase_01 AC 37 ms
144,908 KB
testcase_02 AC 37 ms
144,896 KB
testcase_03 AC 38 ms
144,896 KB
testcase_04 AC 53 ms
145,020 KB
testcase_05 AC 66 ms
145,024 KB
testcase_06 AC 47 ms
145,016 KB
testcase_07 AC 64 ms
144,756 KB
testcase_08 AC 71 ms
144,908 KB
testcase_09 AC 65 ms
144,896 KB
testcase_10 AC 71 ms
144,896 KB
testcase_11 AC 66 ms
145,008 KB
testcase_12 AC 61 ms
145,024 KB
testcase_13 AC 61 ms
144,976 KB
testcase_14 AC 61 ms
144,896 KB
testcase_15 AC 64 ms
144,932 KB
testcase_16 AC 59 ms
144,900 KB
testcase_17 AC 59 ms
144,872 KB
testcase_18 AC 61 ms
144,948 KB
testcase_19 AC 59 ms
145,020 KB
testcase_20 AC 43 ms
145,024 KB
testcase_21 AC 36 ms
144,920 KB
testcase_22 AC 39 ms
144,960 KB
testcase_23 AC 37 ms
144,780 KB
testcase_24 AC 36 ms
145,024 KB
testcase_25 AC 39 ms
145,024 KB
testcase_26 AC 37 ms
144,968 KB
testcase_27 AC 39 ms
145,060 KB
testcase_28 AC 38 ms
144,776 KB
testcase_29 AC 37 ms
144,896 KB
testcase_30 AC 37 ms
144,928 KB
testcase_31 AC 37 ms
144,860 KB
testcase_32 AC 64 ms
144,896 KB
testcase_33 AC 60 ms
144,888 KB
testcase_34 AC 47 ms
145,024 KB
testcase_35 AC 38 ms
144,940 KB
testcase_36 AC 41 ms
144,896 KB
testcase_37 AC 37 ms
144,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int dp[2][3010][3010][2];
int w[3010];
const int mininf=0x88888888;

int main()
{
    int n, m; cin>>n>>m;
    for(int i=0; i<n; ++i) cin>>w[i];

    int res=mininf;
    memset(dp, 0x88, sizeof(dp));
    dp[0][0][0][0]=dp[1][0][1][1]=0;
    for(int h=0; h<2; ++h) {
        for(int i=1; i<n; ++i) {
            for(int j=0; j<=m; ++j) {
                dp[h][i][j][0]=max(dp[h][i-1][j][0], dp[h][i-1][j][1]);
                if (j)
                    dp[h][i][j][1]=max(dp[h][i-1][j-1][0], dp[h][i-1][j-1][1]+w[i]);
            }
        }
        res=max({res, dp[h][n-1][m][0], dp[h][n-1][m][1]+h*w[0]});
    }
    cout<<res<<endl;
}
0