Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Jashwanth27's blog

By Jashwanth27, history, 7 months ago, In English

A family is about to break their piggy bank to use the money for different purposes. The piggy bank here represents an array (arr[]) consisting of N coins. The family has to split the coins of piggy bank into smaller stack (sub-array) of coins such that the sum of the difference between the maximum value and the minimum value of the coins for all the stacks (sub-arrays) is maximum. Note: Each value of the array can be used only once that is only in one subarray.

5 8 1 7 9 2

Ans = 14 -> (8-1) + (9-2) [8,1] max — 8, min = 1 [7 9 2] max = 9 min = 2

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it