262B
262B is a programming problem that appeared in a Codeforces contest. The task is titled “Ciel and Duel” and presents a duel between two players in which each player starts with a hand of cards whose values are integers between 0 and 10. In each round, both participants simultaneously choose a card from their hands. The card with the higher value wins the round. When the values are equal, both players gain a new card whose value is the value of the used card plus one. The winner of a round gains a new card equal to the absolute difference of the two values used in that round. A player may run out of cards, at which point the duel ends. The challenge is to determine which player can finish the duel having collected more “active” cards, assuming both play optimally.
The solution requires analyzing the state of the decks after each possible play. A key observation is
The official editorial outlines a linear‑time algorithm. It first sorts both players’ lists of card values.