Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

Perform two operations on [8, 5, 3, 9]: each operation takes the current largest value x and replaces it with floor(x / 2). What is the sum of all four values after the operations?

  1. A. 16
  2. B. 17
  3. C. 14
  4. D. 12

Correct answer: A. 16

Use a max-heap: first 9 becomes 4, then the largest is 8 which becomes 4. The final values are 4, 5, 4, 3 with total 16.

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

Exams that ask this topic