結果

問題 No.3046 yukicoderの過去問
ユーザー KKT89KKT89
提出日時 2020-08-18 08:00:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,627 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 123,368 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 02:18:01
合計ジャッジ時間 10,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1,575 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1,586 ms
6,940 KB
testcase_06 AC 1,622 ms
6,940 KB
testcase_07 AC 1,615 ms
6,940 KB
testcase_08 AC 1,627 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

constexpr int mod=1000000007;

int n,k,x;
int dp[100010];
int f[100010];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> k >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		f[x]=1;
	}
	dp[0]=1;
	for(int i=0;i<k;i++){
		const int v=dp[i];
		for(int j=0;j<k-i+1;j++){
			dp[i+j]+=v*f[j];
			dp[i+j]-=mod*(dp[i+j]>=mod);
		}
	}
	cout << dp[k] << "\n";
}
0