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 fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";
using ll = long long;
using ii = pair<ll,ll>;
int main() {
int n, L;
cin >> n >> L;
vector<int> v(n);
for(int i = 0; i < n; i++) cin >> v[i];
sort(all(v));
ll ans = 0;
do {
ll cur = 0;
for(int i = 0; i + 1 < n; i++)
cur += abs(v[i] - v[i + 1]);
if(cur <= L) ans++;
} while(next_permutation(all(v)));
cout << ans << "\n";
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... |