#include <bits/stdc++.h>
#include <random>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 2e9+5
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9;
const int MAXK = 1e9;
const int lg = 20;
const int N = 4e4;
const int M = 1e5;
const string SUBTASK = "6";
int sol1(vi a, int n, int l){
int res = 0;
sort(a.begin(), a.end());
do{
int sm = 0;
for(int i = 0; i < n-1; i++){
sm += abs(a[i] - a[i+1]);
}
if(sm <= l) res++;
} while(next_permutation(a.begin(), a.end()));
return res;
}
int main() {
int N,L;
cin >> N >> L;
vi A;
for(int i = 0; i < N; i++){
int a;
cin >> a;
A.pb(a);
}
cout << sol1(A,N,L) << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |