結果
| 問題 |
No.1474 かさまJ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-19 19:02:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 835 bytes |
| コンパイル時間 | 1,860 ms |
| コンパイル使用メモリ | 169,452 KB |
| 実行使用メモリ | 10,016 KB |
| 最終ジャッジ日時 | 2024-09-16 20:43:59 |
| 合計ジャッジ時間 | 5,849 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 -- * 1 |
| other | -- * 17 |
ソースコード
#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;
}