結果

問題 No.3046 yukicoderの過去問
ユーザー KKT89KKT89
提出日時 2020-08-18 08:01:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,558 ms / 2,000 ms
コード長 1,419 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 124,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 02:19:05
合計ジャッジ時間 9,802 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1,558 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1,487 ms
6,940 KB
testcase_06 AC 1,500 ms
6,944 KB
testcase_07 AC 1,513 ms
6,940 KB
testcase_08 AC 1,513 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];

const int BS=524288;

int CNT,rc;
char inb[BS];

inline char gchar(void){
    if(CNT%BS==0){
        CNT=0;
        rc=fread(inb,1,BS,stdin);
    }
    return CNT<rc?inb[CNT++]:0;
}

inline int _readint(int *ptr){
    int n=0,c=0;
    *ptr=0;
    while(1){
        char read=gchar();
        if(read>='0'&&read<='9')read-='0',n*=10,n+=read;
        else{*ptr=n;return n==0?0:!c;}
        c++;
    }
    *ptr=n;
    return 0;
}

inline int readint(void){int ptr;while(_readint(&ptr));return ptr;}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	k=readint();
	n=readint();
	for(int i=0;i<n;i++){
		x=readint();
		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