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;
template <typename T> istream &operator>>(istream &in, vector<T> &arr) {
for (T &el : arr) {
in >> el;
}
return in;
}
int main() {
constexpr int MOD = 1'000'000'007;
int n, l, s, ans = 0;
cin >> n >> l;
vector<int> a(n);
cin >> a;
sort(a.begin(), a.end());
do {
s = 0;
for (int i = 0; i < n - 1; i++) {
s += abs(a[i] - a[i + 1]);
}
if (s <= l) {
ans++;
if (ans == MOD) {
ans = 0;
}
}
} while (next_permutation(a.begin(), a.end()));
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... |