結果

問題 No.783 門松計画
ユーザー veqccveqcc
提出日時 2019-02-15 17:30:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 93,100 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 10:33:59
合計ジャッジ時間 2,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int n, C, l[55], w[55], dp[55][55][55];
map <int, int> mp;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> C;
    for (int i = 1; i <= n; i++) cin >> l[i];
    for (int i = 1; i <= n; i++) cin >> w[i];

    int ans = 0;
    for (int c = 1; c <= C; c++) { // cost
        for (int q = 0; q <= n; q++) { // 2こ前
            for (int p = 0; p <= n; p++) { // 1こ前
                for (int i = 1; i <= n; i++) { // 今加えようとしてるもの
                    if (l[p] == l[i] || l[i] == l[q]) continue;
                    if (q && p && l[q] < l[p] && l[p] < l[i]) continue;
                    if (q && p && l[q] > l[p] && l[p] > l[i]) continue;
                    if (c < w[i]) continue;
                    dp[c][p][i] = max(dp[c][p][i], dp[c - w[i]][q][p] + l[i]);
                    if (q && p) ans = max(ans, dp[c][p][i]);
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}
0