标签:
a=[2,4,3,6,1]
b=[5,2,3,1,7]
tasks = zip(a,b)
tasks_no= zip(tasks, range(1,6))
_list1 = sorted(filter(lambda item:item[0][0] < item[0][1], tasks_no))
_list2 = sorted(filter(lambda item:item[0][0] >=item[0][1], tasks_no),
key = lambda item:item[0][1], reverse=True)
_list = _list1 + _list2
_res = zip(*_list)[1]
_seq = zip(*_list)[0]
print _seq
_seq2= zip(*_seq)
part1 = _list[0][0][0]
part2 = part1 + _list[0][0][1]
for i in range(1,5):
part1 = part1 + _list[i][0][0]
part2 = part1 + _list[i][0][1] if part1>part2 else part2+_list[i][0][1]
print part2
Dynamic programming--task schedule
标签:
原文地址:http://www.cnblogs.com/zhaodonglin/p/5533347.html