# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118243 | vjudge1 | Skyscraper (JOI16_skyscraper) | C++17 | 0 ms | 0 KiB |
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;
ranges::sort(a);
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 (ranges::next_permutation(a).found);
cout << ans << '\n';
return 0;
}