結果

問題 No.3046 yukicoderの過去問
ユーザー beetbeet
提出日時 2019-04-03 20:49:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,728 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 73,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 20:51:29
合計ジャッジ時間 9,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include<iostream>
using namespace std;

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
const int MAX = 1<<17;
const int MOD = 1e9+7;
int x[MAX]={};
int dp[MAX]={};

signed main(){
  int k,n;
  cin>>k>>n;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    x[p]=1;
  }
  dp[0]=1;
  for(int l=0;l<k;l++){
    const int v=dp[l]%MOD;
    for(int i=0;l+i<=k;i++){
      dp[l+i]+=v*x[i];
      dp[l+i]-=MOD*(dp[l+i]>=MOD);
    }
  }
  cout<<dp[k]<<endl;
  return 0;
}

0