結果

問題 No.3046 yukicoderの過去問
ユーザー risujirohrisujiroh
提出日時 2019-04-02 02:58:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 895 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 184,316 KB
実行使用メモリ 10,912 KB
最終ジャッジ日時 2024-05-05 13:40:48
合計ジャッジ時間 5,949 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
int read_int(){int c,r;while((c=getchar())<48);r=c-48;while((c=getchar())>47)r=r*10+c-48;return r;}
void write_int(int x){int b[10],*p=b;do*p++=48+x%10,x/=10;while(x);do putchar(*--p);while(p>b);}

constexpr int mod = 1e9 + 7;

int main() {
  int k = read_int();
  int n = read_int();
  V<> x(n);
  for (int i = 0; i < n; ++i) x[i] = read_int();
  V<> dp(k + 1);
  dp[0] = 1;
  for (int j = 0; j < k; ++j) {
    for (int i = 0; i < n; ++i) {
      if (j + x[i] > k) break;
      if ((dp[j + x[i]] += dp[j]) >= mod) dp[j + x[i]] -= mod;
    }
  }
  cout << dp[k] << '\n';
}
0