Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional
Two players alternately take a pile from either END of the row [4, 15, 3, 9, 2, 8]; the first player moves first and each takes the whole pile they choose. Both play optimally to maximise their own total. What is the maximum total the FIRST player can guarantee?
- A. 20
- B. 35
- C. 33
- D. 32
Correct answer: D. 32
Interval game DP: f(i, j) = max over taking a[i] or a[j] of (the pile + the minimum of what the opponent can force on the remaining range). Greedy by taking the larger visible end is a trap, since it can leave the opponent a stronger position.
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
- You may partition the multiset [3, 1, 4, 1, 5, 9, 2, 6] into as many GROUPS as possible, where every group must have sum at least 7 and…
- From the numbers [7, 2, 9, 4, 1, 6, 3], choose the largest possible number of elements (each used at most once) whose total is at most 12…
- Choose two different elements of [-8, 1, 5, 9, 12, 20, 33] whose sum is as close as possible to the target 30. What is that sum?
- Each turn you pick a number x from [3, 4, 2, 4, 4, 6], earn x points, and then delete EVERY copy of x−1 and x+1. You may keep doing this…
- How many contiguous subarrays of 2 5 1 3 5 2 4 have a sum EXACTLY equal to 5, the maximum value of the whole array?
- How many contiguous subarrays of length exactly 3 in 1 2 3 4 4 1 5 7 have bitwise XOR equal to 0?