結果

問題 No.1238 選抜クラス
ユーザー y61mpnl
提出日時 2020-09-26 00:15:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 194,036 KB
最終ジャッジ日時 2025-01-14 21:46:51
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b;i<e;i++)
using ll = int_fast64_t;
const int MOD = 1e9+7;

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    REP(i, 0, n){
        scanf("%d", &a[i]);
        a[i] -= k;
    }

    ll dp[1+n][20200] = {};
    dp[0][10100] = 1;
    REP(i, 1, 1+n){
        REP(j, 0, 20200){
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= MOD;
            if(j<a[i-1] or 20200<=j-a[i-1]) continue;
            dp[i][j] += dp[i-1][j-a[i-1]];
            dp[i][j] %= MOD;
        }
    }

    ll ans = 0;
    REP(i, 10100, 20200){
        ans += dp[n][i];
        ans %= MOD;
    }

    printf("%ld\n", (ans-1+MOD)%MOD);
    return 0;
}
0