結果
| 問題 |
No.8046 yukicoderの過去問
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-04-02 03:05:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 914 bytes |
| コンパイル時間 | 2,173 ms |
| コンパイル使用メモリ | 182,640 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-11-27 11:42:05 |
| 合計ジャッジ時間 | 17,636 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 5 |
ソースコード
#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;
constexpr int N = 1e5;
int dp[N + 1], f[N + 1];
int main() {
int k = read_int();
int n = read_int();
for (int i = 0; i < n; ++i) {
f[read_int()] = 1;
}
dp[0] = 1;
for (int j = 0; j < k; ++j) {
for (int i = 0; j + i <= k; ++i) {
dp[j + i] += f[i] * dp[j];
dp[j + i] -= (dp[j + i] >= mod) * mod;
}
}
cout << dp[k] << '\n';
}
risujiroh