Submission #852889

#TimeUsernameProblemLanguageResultExecution timeMemory
852889iamjiamingliuA Huge Tower (CEOI10_tower)Cpython 3
5 / 100
1103 ms262144 KiB
import sys _, diff = map(int, input().split()) nums = list(map(int, sys.stdin.readline().strip().split())) dp = [[0] * len(nums) for _ in range(1 << len(nums))] for i in range(len(nums)): dp[1 << i][i] = 1 for subset in range(1 << len(nums)): used = [nums[i] for i in range(len(nums)) if (1 << i) & subset] remaining = [nums[i] for i in range(len(nums)) if (1 << i) & ~subset] if max(remaining, default=0) > max(used, default=0) + diff: dp[subset] = [0] * len(nums) continue for last in range(len(nums)): if (1 << last) & subset: for prev_last in range(len(nums)): if (1 << prev_last) & subset and nums[last] <= nums[prev_last] + diff: dp[subset][last] += dp[subset ^ (1 << last)][prev_last] print(sum(dp[-1]) % (10 ** 9 + 9))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...