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;
#define int long long
void solve(){
int n, k;
cin >> n >> k;
int a[n];
for(int i = 0; i < n; ++i){
cin >> a[i];
}
sort(a, a + n);
int res = 0;
do{
int sum = 0;
bool check = true;
for(int i = 1; i < n; ++i){
sum += abs(a[i] - a[i - 1]);
if(sum > k){
check = false;
break;
}
}
if(check){
res++;
}
}while(next_permutation(a, a + n));
cout << res << endl;
}
signed main(){
int T = 1;
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... |