結果

問題 No.3046 yukicoderの過去問
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-04-02 16:25:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,767 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 34,128 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 05:19:09
合計ジャッジ時間 9,382 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("avx")

#include <stdio.h>

constexpr int MO = 1000000007;

int K, N;

int a[100010];
int dp[100010];

int main() {
  scanf("%d", &K);
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int x;
    scanf("%d", &x);
    a[x] = 1;
  }
  dp[0] = 1;
  for (int y = 0; y < K; ++y) {
    const int c = dp[y];
    for (int x = 1; x <= K - y; ++x) {
      if ((dp[y + x] += a[x] * c) >= MO) {
        dp[y + x] -= MO;
      }
    }
  }
  printf("%d\n", dp[K]);
  return 0;
}
0