#include <bits/stdc++.h>
//#include <__msvc_all_public_headers.hpp>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, L, Ai, total = 0;
cin >> N >> L;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> Ai;
list[i] = Ai;
}
sort(list.begin(), list.end());
do {
long long sum = 0;
for (int i = 1; i < N; i++) {
sum += abs(list[i - 1] - list[i]);
}
if (sum <= L) {
total++;
total %= 1000000007;
}
} while (next_permutation(list.begin(), list.end()));
cout << total;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |