結果

問題 No.1474 かさまJ
ユーザー chocoruskchocorusk
提出日時 2021-04-09 22:42:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,777 bytes
コンパイル時間 3,561 ms
コンパイル使用メモリ 189,916 KB
実行使用メモリ 545,196 KB
最終ジャッジ日時 2023-09-07 12:17:52
合計ジャッジ時間 10,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
mint dp[41][41][40040], dps[41][41][40040];
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n, mp, mq, l;
    cin>>n>>mp>>mq>>l;
    int s[44];
    for(int i=0; i<n; i++) cin>>s[i];
    dp[0][0][0]=1;
    for(int i=1; i<=mq+1; i++) dps[0][0][i]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            for(int k=0; k<=mq; k++){
                dp[i+1][j][k]+=dp[i][j][k];
                dp[i+1][j+1][k]+=dps[i][j][k]-dps[i][j][max(0, k-s[i])];
            }
        }
        for(int j=0; j<=i+1; j++){
            for(int k=0; k<=mq; k++){
                dps[i+1][j][k+1]=dps[i+1][j][k]+dp[i+1][j][k];
            }
        }
    }
    fac(100010);
    mint ans=0;
    for(int i=0; i<=mq; i++){
        for(int j=0; j<=n; j++){
            if(l*j-i<0) continue;
            ans+=dp[n][j][i]*comb(mp-l*j+i+n-1, n-1);
        }
    }
    cout<<ans.val()<<endl;
    return 0;
}
0