Submission #852896

# Submission time Handle Problem Language Result Execution time Memory
852896 2023-09-23T04:56:32 Z iamjiamingliu A Huge Tower (CEOI10_tower) Python 3
100 / 100
784 ms 77752 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

left_i = 0
for i, n in enumerate(nums):
    while n > nums[left_i] + diff:
        left_i += 1
    ways[i + 1] = (ways[i] * (i - left_i + 1)) % MOD

print(ways[-1])
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2980 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 12 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2828 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 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 13 ms 2752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 3160 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 14 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 11 ms 2992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 8464 KB Output is correct
2 Correct 50 ms 8464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 301 ms 30716 KB Output is correct
2 Correct 277 ms 30484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 612 ms 75064 KB Output is correct
2 Correct 784 ms 77752 KB Output is correct