Submission #886516

# Submission time Handle Problem Language Result Execution time Memory
886516 2023-12-12T09:12:15 Z stefanneagu A Huge Tower (CEOI10_tower) C++17
20 / 100
181 ms 8780 KB
#include <bits/stdc++.h>
using namespace std;

const int nmax = 1e6 + 1;

int v[nmax], n, h, ans;
bool f[nmax];

void dfs(int x, int cnt) {
  if(cnt == n) {
    ans ++;
  }
  for(int i = 1; i <= n; i ++) {
    if(!f[i] && v[x] + h >= v[i]) {
      f[i] = 1;
      dfs(i, cnt + 1);
      f[i] = 0;
    }
  }
}

int main() {
  cin >> n >> h;
  for(int i = 1; i <= n; i ++) {
    cin >> v[i];
  }
  assert(n < 15);
  sort(v + 1, v + n + 1, greater<int>());
  for(int i = 1; i <= n; i ++) {
    f[i] = 1;
    dfs(i, 1);
    f[i] = 0;
  }
  cout << ans;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 2464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 4540 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 77 ms 4512 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 181 ms 8780 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -