Submission #297110

#TimeUsernameProblemLanguageResultExecution timeMemory
297110arman_ferdousSkyscraper (JOI16_skyscraper)C++17
5 / 100
2068 ms384 KiB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<ll,ll>;

int main() {
  int n, L;
  cin >> n >> L;
  vector<int> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];

  sort(all(v));
  ll ans = 0;
  do {
    ll cur = 0;
    for(int i = 0; i + 1 < n; i++)
      cur += abs(v[i] - v[i + 1]);
    if(cur <= L) ans++;
  } while(next_permutation(all(v)));
  cout << ans << "\n";
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...