結果

問題 No.3046 yukicoderの過去問
ユーザー okkuukenkenokkuukenken
提出日時 2022-08-19 14:47:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,415 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 4,869 ms
コンパイル使用メモリ 291,304 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 19:36:17
合計ジャッジ時間 11,878 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1,130 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1,134 ms
5,376 KB
testcase_06 AC 1,406 ms
5,376 KB
testcase_07 AC 1,405 ms
5,376 KB
testcase_08 AC 1,415 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int flg[100001];
int dp[100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int k,n,x;
	cin>>k>>n;
	while(cin>>x)
		flg[x]=1;
	dp[0]=1;
	for(int i=0;i<k;i++){
		const int tmp=dp[i];
		for(int j=1;j<=k-i;j++){
			dp[j+i]+=tmp*flg[j];
			dp[j+i]-=mod*(dp[j+i]>=mod);
		}
	}
	cout<<dp[k]<<endl;
}
0