結果

問題 No.1474 かさまJ
ユーザー gorugo30gorugo30
提出日時 2021-02-19 19:02:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 835 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 168,164 KB
実行使用メモリ 7,828 KB
最終ジャッジ日時 2023-10-15 03:11:59
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int N, MP, Mq, L;
vector<int> S;

long solve(int i, int rP, int rq){
    if (i == N){
        if (rP == 0) return 1;
        return 0;
    }
    long ans = 0;
    for (int mP = 0; mP <= rP; mP++){
        ans = (ans + solve(i + 1, rP - mP, rq)) % MOD;
    }
    for (int mq = 1; mq <= min(rq, S[i]); mq++){
        if (mq + rP < L) continue;
        int needP = L - mq;
        if (needP < 0) continue;
        for (int mP = needP; mP <= rP; mP++){
            ans = (ans + solve(i + 1, rP - mP, rq - mq)) % MOD;
        }
    }
    return ans;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N >> MP >> Mq >> L;
    S.resize(N);
    for (int i = 0; i < N; i++){
        cin >> S[i];
    }

    cout << solve(0, MP, Mq) << endl;
}
0