Copy Books II - non-optimized ve

2018-04-09  本文已影响0人  Star_C

Question

from lintcode
Given n books( the page number of each book is the same) and an array of integer with size k means k people to copy the book and the i th integer is the time i th person to copy one book). You must distribute the continuous id books to one people to copy. (You can give book A[1],A[2] to one people, but you cannot give book A[1], A[3] to one people, because book A[1] and A[3] is not continuous.) Return the number of smallest minutes need to copy all the books.
Example
Given n = 4, array A = [3,2,4], .

Return 4( First person spends 3 minutes to copy book 1, Second person spends 4 minutes to copy book 2 and 3, Third person spends 4 minutes to copy book 4. )

Idea

You can give arbitrary books to current person, and give the remained ones to next person... Try all possibilities by DFS search. Remember to cache some calculated results.

Note: This solution can only pass 65% of the test cases. I will update a better one later.

``java
/**

上一篇 下一篇

猜你喜欢

热点阅读