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?
- A. 94
- B. 167
- C. 192
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many non-empty contiguous subarrays of [4, -2, 7, -5, 3, 6] have a sum of at most 4?
- Starting from n = 191, in each step you may replace n by n/2 when n is even, or by n−1 or n+1 when n is odd. What is the minimum number of…
- Coins of value 2, 3 and 5 are available in unlimited supply. In how many ways can you pay exactly 10 when the ORDER of coins does NOT…
- In the binary array [1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1] you may flip at most ONE 0 to a 1. What is the length of the longest run of…
- What is the length of the longest STRICTLY increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7, 6, 7, 8, 2]?
- For the array [1, 3, 5, 4, 7, 2, 2, 8, 6, 9], how many DIFFERENT subsequences (chosen by index) are strictly increasing AND have the…