Submission #886510

# Submission time Handle Problem Language Result Execution time Memory
886510 2023-12-12T09:11:11 Z stefanneagu A Huge Tower (CEOI10_tower) C++17
20 / 100
1000 ms 8872 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 < 20);
  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 2392 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 92 ms 2468 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 Execution timed out 1018 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 2396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 2392 KB Time limit exceeded
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 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 3 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 70 ms 4512 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 177 ms 8872 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -