結果
問題 | No.8046 yukicoderの過去問 |
ユーザー |
|
提出日時 | 2020-05-07 01:57:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 423 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 30,208 KB |
最終ジャッジ日時 | 2025-01-10 07:23:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d",&k,&n); | ~~~~~^~~~~~~~~~~~~~ main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | int a; scanf("%d",&a); | ~~~~~^~~~~~~~~
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include <cstdio> using namespace std; constexpr int MOD=1e9+7; int k,n,f[100001],dp[100001]; int main(){ scanf("%d%d",&k,&n); for(int i=0;i<n;i++){ int a; scanf("%d",&a); f[a]=1; } dp[0]=1; for(int x=0;x<k;x++){ int v=dp[x]; for(int y=0;x+y<=k;y++){ dp[x+y]+=f[y]*v; if(dp[x+y]>=MOD) dp[x+y]-=MOD; } } printf("%d\n",dp[k]); return 0; }