結果

問題 No.8046 yukicoderの過去問
ユーザー hirakich1000000007
提出日時 2019-04-01 22:45:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 531 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 30,976 KB
最終ジャッジ日時 2025-01-07 01:09:43
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%lld%lld", &k, &n);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:15:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     for (i = 0; i < n; i++) scanf("%lld", &a[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")

#include <stdio.h>
typedef long long int ll;

ll dp[200000];
ll a[200000];
ll MOD = 1000000007;
int main(void){
    ll k, n;
    ll i, j;
    scanf("%lld%lld", &k, &n);
    for (i = 0; i < n; i++) scanf("%lld", &a[i]);
    
    dp[0] = 1;
    for (i = 1; i <= k; i++) {
        for (j = 0; j < n; j++) {
            if (a[j] > i) break;
            dp[i] = (dp[i] + dp[i - a[j]]) % MOD;
        }
    }
    
    printf("%llu\n", dp[k]);
}
0