This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
n <= 8
Check all possible permutations
*/
int main() {
int N, L;
cin >> N >> L;
int a[N];
for(int i = 0; i < N; i++) {
cin >> a[i];
}
sort(a, a + N);
ll count = 0;
do {
ll dif = 0;
for(int i = 1; i < N; i++) {
dif += abs(a[i] - a[i - 1]);
}
if(dif <= L) {
count++;
}
} while(next_permutation(a, a + N));
cout << count << 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... |