Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

legar's blog

By legar, history, 9 years ago, In English

You are given a list L of N integers. < 1000 Let's define an operation of cutting the list as follows: Suppose L = {l1, l2, ..., li, li+1, ..., lN}, then, cutting the list L at index i will split L into two nonempty sub-lists L1= {l1, l2, ...; li} and L2= {li+1, li+2, ..., lN}. Now, for each of sub-list Li, we can find the difference between the maximum value (Mi) and minimum value (mi) of Li and call it di. The task is to cut the list into K sub-list (1 ≤ K ≤ N) so that ans = d1+d2+....+dk, is minimized. Print ans. (1 ≤ K ≤ N ≤ 1000). The O(N*N*K) solution is very slow. Thanks.

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it