Submission #809149

# Submission time Handle Problem Language Result Execution time Memory
809149 2023-08-05T19:23:26 Z jackliy369 A Huge Tower (CEOI10_tower) Python 3
90 / 100
1000 ms 75792 KB
N, D = map(int, input().split())
blocks = sorted(list(map(int, input().split())))

def binary_search(l, r, size, list):
    ans = r + 1
    while r >= l:
        m = (l + r) // 2
        # m = l + floor(log10(r - l + 1))
        # m = l + (r - l) // 1000000
        if size <= list[m] + D:
            r = m - 1
            ans = m
        else:
            l = m + 1
    return ans

ans = 1
i = 0
for j in range(1, N):
    while i < j and blocks[j] > blocks[i] + D:
        i += 1
    # i = binary_search(i, j - 1, blocks[j], blocks)
    ans *= j - i + 1

print(ans % 1000000009)
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 2864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 455 ms 8328 KB Output is correct
2 Correct 557 ms 8808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 30476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 75792 KB Time limit exceeded
2 Halted 0 ms 0 KB -