URAL 1876. Centipedes Morning (贪心)

A centipede has 40 left feet and 40 right feet. It keepsaleft slippers andbright slippers under its bed. Every morning the centipede puts on the slippers. It pokes its first left foot under the bed and puts on a random slipper, doing it in one second. If the slipper is left, the centipede passes to shoeing the second left foot. Otherwise, it takes off the slipper and puts it on any unshod right foot, spending one more second, so that it takes two seconds altogether to put on such a slipper. If there are no unshod right feet, the centipede throws the slipper to a corner of the room, also in one second, so that two seconds are spent altogether for this slipper. The process is continued until all the left feet are in left slippers. Then the centipede starts shoeing its right feet until all of them are shod.

,穿越茫茫人海,寻找属于我们的那一份宁静。

URAL 1876. Centipedes Morning (贪心)

相关文章:

你感兴趣的文章:

标签云: