LintCode: Paint House II
2016-04-25 23:50
501 查看
LintCode: Paint House II
最简单的穷举法,可惜超时了,先留个坑~
最简单的穷举法,可惜超时了,先留个坑~
class Solution: # @param {int[][]} costs n x k cost matrix # @return {int} an integer, the minimum cost to paint all houses def minCostII(self, costs): # Write your code here if len(costs) == 0: return 0 n = len(costs) k = len(costs[0]) L = [[0 for i in range(k)] for i in range(n + 1)] for i in range(1, n + 1): for j in range(k): tmp = [] for m in range(k): if m != j: tmp.append(costs[i-1][j] + L[i-1][m]) L[i][j] = min(tmp) return min(L )
相关文章推荐
- (整理)IIS 7 503 "service unavailable" errors
- AD的一些信息
- paintEvent调用时机
- LogCat里的错误提示 FATAL EXCEPTION: main
- LintCode:Paint House
- HDU 2476 String painter 区间dp
- 概率图模型
- bnu 51641 Certain Maze(bfs)(北师16校赛)
- caption标签,为表格添加标题和摘要 summary a mail
- bnu 51638 Air Hockey(三分+二分)(北师16校赛)
- hdu1302The Snail
- bnu 51640 Training Plan(类似区间dp)(北师16校赛)
- HDU 1023 Train ProblemII
- LeeCode-Contains Duplicate
- 关于main函数中argc和argv的简单介绍
- Fast-Start Failover工作过程及实例
- OpenGL vs2010 ActiveX Control Test Container
- B. Kuriyama Mirai's Stones
- POJ2010-Moo University - Financial Aid
- 设计模式之---责任链模式(Chain of Responsibility)