結果

問題 No.1956 猫の額
ユーザー testestesttestestest
提出日時 2022-05-23 17:45:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 576 bytes
コンパイル時間 5,468 ms
コンパイル使用メモリ 205,600 KB
実行使用メモリ 21,824 KB
最終ジャッジ日時 2023-10-20 18:19:25
合計ジャッジ時間 11,332 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 15 ms
5,704 KB
testcase_02 MLE -
testcase_03 AC 26 ms
6,496 KB
testcase_04 AC 475 ms
13,888 KB
testcase_05 AC 398 ms
13,096 KB
testcase_06 AC 414 ms
12,304 KB
testcase_07 AC 43 ms
5,176 KB
testcase_08 MLE -
testcase_09 AC 61 ms
8,080 KB
testcase_10 MLE -
testcase_11 AC 255 ms
10,460 KB
testcase_12 AC 358 ms
11,248 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 57 ms
4,648 KB
testcase_15 AC 18 ms
5,968 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	int N,C,mod;
	cin >> N >> mod >> C;
	bool invert=false;
	if(C>N/2){
		invert=true;
		C=N-C;
	}
	
	vector<int>A(N);
	int S=0;
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++)S+=A[i];

	vector<vector<int>>dp(C+1,vector<int>(S+1));
	int sum=0;
	dp[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=min(i,C-1);j>=0;j--){
			for(int k=0;k<=min(sum,S-A[i]);k++)(dp[j+1][k+A[i]]+=dp[j][k])%=mod;
		}
		sum+=A[i];
	}
	for(int i=1;i<=S;i++){
		if(i!=1)cout << ' ';
		cout << (invert?dp[C][S-i]:dp[C][i]);
	}
	cout << '\n';
}
0