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