This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
const long double EPS=1e-9;
const int MOD=1e9+7;
const int N=1e6;
int n,m,a[105];
bool ok(){
int sm = 0;
for(int i = 0 ; i < n - 1 ; i ++){
sm += abs(a[i] - a[i + 1]);
}
return sm <= m;
}
in main(){
cin >> n >> m;
for(int i = 0 ; i < n ; i ++){
cin >> a[i];
}
sort(a,a + n);
int ans = 0;
do{
ans += ok();
}
while(next_permutation(a,a + n));
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |