A Game of Cards

Limits: 1s, 512 MB

Alice and Bob got bored and came up with a new game.

They put N cards in a row on a table. The cards have IDs 1 to N from left to right. Each card has a positive integer written on it.

This is a companion discussion topic for the original entry at https://toph.co/p/a-game-of-cards