L437 copy books I
Given_n_books and the_i_th book hasA[i]
pages. You are given_k_people to copy the_n_books.
the_n_books list in a row and each person can claim a continuous range of the_n_books. For example one copier can copy the books from_i_th to_j_th continously, but he can not copy the 1st book, 2nd book and 4th book (without 3rd book).
They start copying books at the same time and they all cost 1 minute to copy 1 page of a book. What's the best strategy to assign books so that the slowest copier can finish at earliest time?
Example
Given array A =[3,2,4]
, k =2
.
Return5
( First person spends 5 minutes to copy book 1 and book 2 and second person spends 4 minutes to copy book 3. )
方法一:2分答案。O(nlog(range))
方法二:DP
Last updated
Was this helpful?