結果

問題 No.783 門松計画
ユーザー rickythetarickytheta
提出日時 2019-01-11 21:50:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 1,417 ms
コンパイル使用メモリ 144,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 05:35:13
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int n,c;
int l[52], w[52];

int dp[52][52][52];
const int INF = 252521;

int main(){
    scanf("%d%d",&n,&c);
    REP(i,n)scanf("%d",l+i);
    REP(i,n)scanf("%d",w+i);
    REP(i,52)REP(j,52)REP(k,52)dp[i][j][k] = -INF;
    dp[0][0][51] = dp[0][51][0] = 0;
    REP(sw,c)REP(b2,52)REP(b1,52)if(dp[sw][b2][b1]>=0){
        REP(i,n){
            if(b2==l[i] || b1==l[i])continue;
            if(b2<b1 && b1<l[i])continue;
            if(b2>b1 && b1>l[i])continue;
            int nw = sw + w[i];
            if(nw>c)continue;
            dp[nw][b1][l[i]] = max(dp[nw][b1][l[i]], dp[sw][b2][b1] + l[i]);
        }
    }
    int ans = 0;
    REP(i,c+1)REP(j,50)REP(k,50)ans = max(ans, dp[i][j+1][k+1]);
    printf("%d\n",ans);
    return 0;
}
0