Submission #1118245

#TimeUsernameProblemLanguageResultExecution timeMemory
1118245vjudge1Skyscraper (JOI16_skyscraper)C++17
5 / 100
2048 ms592 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...