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 all(v) v.begin(), v.end()
using LL = long long;
int main() {
cin.tie(nullptr) -> ios_base::sync_with_stdio(false);
int tests = 1;
// cin >> tests;
while (tests--) {
int n, k;
cin >> n >> k;
vector <int> v (n), other (n);
for (auto &i : v) cin >> i;
iota (all (other), 0);
int ans = 0;
do {
int sum = 0;
for (int i = 1; i < n; i++) sum += abs (v[other[i]] - v[other[i - 1]]);
ans += sum <= k;
} while (next_permutation (all (other)));
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... |