이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |