0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-27 05:11:59 +00:00
OI-codes/Luogu/P1164/P1164.cpp

27 lines
587 B
C++
Raw Normal View History

2020-10-18 07:58:38 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a[10005], f[10005][10005];
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (j == a[i]) {
f[i][j] = f[i - 1][j] + 1;
}
if (j > a[i]) {
f[i][j] = f[i - 1][j] + f[i - 1][j - a[i]];
}
if (j < a[i]) {
f[i][j] = f[i - 1][j];
}
}
}
cout << f[n][m] << endl;
return 0;
}