F - PC on the Table Editorial by spheniscine Editorial for printing


PCs can never be placed vertically, so we can consider each row individually. We can also note that within each row, we could place \(\lfloor x / 2 \rfloor\) PCs in a “run” of \(x\) characters T. Thus, a greedy strategy that “wastes” \(0\) or \(1\) spaces at the end of each run will suffice as a solution.

posted:
last update: