#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, l; cin >> n >> l;
vector<int> heights(n);
for (int &i : heights) cin >> i;
sort(heights.begin(), heights.end());
int res = 0;
do {
int tot = 0;
for (int i = 0; i < n - 1; ++i) tot += abs(heights[i] - heights[i + 1]);
res += (tot <= l);
} while (next_permutation(heights.begin(), heights.end()));
cout << res << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |