結果

問題 No.1956 猫の額
ユーザー 37zigen37zigen
提出日時 2022-04-21 16:41:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 735 bytes
コンパイル時間 1,753 ms
コンパイル使用メモリ 79,024 KB
実行使用メモリ 41,236 KB
最終ジャッジ日時 2023-10-20 18:00:04
合計ジャッジ時間 42,382 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 30 ms
10,372 KB
testcase_02 MLE -
testcase_03 AC 62 ms
12,420 KB
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 6 ms
8,324 KB
testcase_14 MLE -
testcase_15 AC 41 ms
10,372 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <limits>
#include <queue>
#include <vector>
#include <iostream>

using namespace std;

const int NMAX = 100;
const int AMAX = 100000;
int a[NMAX];
int dp[NMAX + 1][AMAX + 1];

int N, M, C;

int main() {
	cin >> N >> M >> C;
	for (int i = 0; i < N; ++i) cin >> a[i];
	for (int i = 0; i < N; ++i) for (int j = 0; j <= AMAX; ++j) dp[i][j] = 0;
	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j >= 0; --j) {
			for (int k = AMAX - a[i]; k >= 0; --k) {
				dp[j + 1][k + a[i]] += dp[j][k];
				dp[j + 1][k + a[i]] %= M;
			}
		}
	}
	int max = 0;
	for (int i : a) max += i;
	long long ans = 0;
	for (int s = 1; s <= max; ++s) cout << dp[C][s] << (s == max ? "\n" : " ");
}
0