Submission #852895

# Submission time Handle Problem Language Result Execution time Memory
852895 2023-09-23T04:55:35 Z iamjiamingliu A Huge Tower (CEOI10_tower) Python 3
100 / 100
863 ms 81340 KB
import sys
import bisect

MOD = 10 ** 9 + 9

_, diff = map(int, input().split())
nums = list(map(int, sys.stdin.readline().strip().split()))
nums.sort()

ways = [0] * (len(nums) + 1)
ways[0] = 1

for i, n in enumerate(nums):
    positions = i - bisect.bisect_left(nums, n - diff) + 1
    ways[i + 1] = (ways[i] * positions) % MOD

print(ways[-1])
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 8888 KB Output is correct
2 Correct 62 ms 8976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 33140 KB Output is correct
2 Correct 297 ms 33092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 788 ms 79112 KB Output is correct
2 Correct 863 ms 81340 KB Output is correct