#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define ll long long
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int gcd(int a, int b){
return __gcd(a, b);
}
int lcm(int a, int b){
return a / gcd(a, b) * b;
}
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
void solve(){
int n, L;
cin >> n >> L;
vector<int> vt;
for (int i = 1; i <= n; i++ ){
int a;
cin >> a;
vt.push_back(a);
}
sort(vt.begin(), vt.end());
int ans = 0;
do{
int sum = 0;
for (int i = 1; i < vt.size(); i++ ){
sum += abs(vt[i] - vt[i - 1]);
}
if(sum <= L)ans++;
ans %= (int) 1e9 + 7;
}while(next_permutation(vt.begin(), vt.end()));
cout << ans << endl;
}
signed main(){
IOS;
int t = 1;
//cin >> t;
while (t--){
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |