結果

問題 No.1956 猫の額
ユーザー suisensuisen
提出日時 2022-05-24 00:56:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 937 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 21,840 KB
最終ジャッジ日時 2023-10-20 18:40:16
合計ジャッジ時間 6,212 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 12 ms
5,696 KB
testcase_02 MLE -
testcase_03 AC 16 ms
6,488 KB
testcase_04 AC 195 ms
13,880 KB
testcase_05 AC 165 ms
13,088 KB
testcase_06 AC 168 ms
12,296 KB
testcase_07 AC 25 ms
5,168 KB
testcase_08 MLE -
testcase_09 AC 28 ms
8,072 KB
testcase_10 MLE -
testcase_11 AC 100 ms
10,452 KB
testcase_12 AC 140 ms
11,240 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 24 ms
4,640 KB
testcase_15 AC 13 ms
5,960 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>

#include <atcoder/modint>

using mint = atcoder::modint;

constexpr int N = 100000;

int main() {
    int n, m, c;
    std::cin >> n >> m >> c;
    mint::set_mod(m);

    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;

    std::sort(a.begin(), a.end(), std::greater<int>());

    const int s = std::accumulate(a.begin(), a.end(), 0);

    bool take_compl = 2 * c >= n;
    if (take_compl) {
        c = n - c;
    }

    std::vector dp(c + 1, std::vector<mint>(s + 1));
    dp[0][0] = 1;
    for (int val : a) {
        for (int num = std::min(c, s / val); num >= 1; --num) {
            for (int sum = num * val; sum <= s; ++sum) {
                dp[num][sum] += dp[num - 1][sum - val];
            }
        }
    }

    for (int sum = 1; sum <= s; ++sum) {
        std::cout << dp[c][take_compl ? s - sum : sum].val() << " \n"[sum == s];
    }

    return 0;
}
0