Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

Balloons with values [3, 1, 5, 8, 2] are burst one at a time. Bursting balloon i gives coins = left × value[i] × right, where left and right are the neighbours still present (outside the array counts as 1). Burst order is free. What is the maximum number of coins?

  1. A. 94
  2. B. 167
  3. C. 192
  4. D. 187

Correct answer: C. 192

Think of the LAST balloon burst in an interval: it sees the fixed walls at both ends. Interval DP over sub-ranges with a chosen last balloon gives the answer; bursting the smallest balloon first is a greedy trap that does not hold in general.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic