結果

問題 No.1956 猫の額
ユーザー testestesttestestest
提出日時 2022-05-23 17:44:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 671 bytes
コンパイル時間 4,947 ms
コンパイル使用メモリ 266,108 KB
実行使用メモリ 21,844 KB
最終ジャッジ日時 2023-10-20 18:19:11
合計ジャッジ時間 8,474 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 13 ms
5,740 KB
testcase_02 MLE -
testcase_03 AC 17 ms
6,532 KB
testcase_04 AC 197 ms
13,924 KB
testcase_05 AC 165 ms
13,132 KB
testcase_06 AC 166 ms
12,340 KB
testcase_07 AC 23 ms
5,212 KB
testcase_08 MLE -
testcase_09 AC 29 ms
8,116 KB
testcase_10 MLE -
testcase_11 AC 108 ms
10,496 KB
testcase_12 AC 146 ms
11,284 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 25 ms
4,684 KB
testcase_15 AC 13 ms
6,004 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

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];

	modint::set_mod(mod);
	vector<vector<modint>>dp(C+1,vector<modint>(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];
		}
		sum+=A[i];
	}
	for(int i=1;i<=S;i++){
		if(i!=1)cout << ' ';
		cout << (invert?dp[C][S-i]:dp[C][i]).val();
	}
	cout << '\n';
}
0