This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 110, mod = 1000007;
int n, m;
int f[N][N]; // f[i, j] 表示前i个物品,总体积是j的方案数
int main() {
cin >> n >> m;
f[0][0] = 1; // 求方案数的base case
for (int i = 1; i <= n; i++) {
int a;
cin >> a; // 最多允许选a个
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= min(a, j); k++)
f[i][j] = (f[i][j] + f[i - 1][j - k]) % mod;
}
cout << f[n][m] << endl;
return 0;