Moving Day
Description
You and several roommates are coordinating a move out into several new apartments. Only two trucks of different sizes are available from a moving truck rental company. Imagine you are tasked with generating a solution that would figure out a trip plan for all roommates to transport their large and small items to their new homes.
What additional information will you need in order to solve this problem?
这道 Wayfair 搬家装车题的核心是把“每趟车能装多少件物品”抽象成容量约束,再通过贪心或模拟计算最少需要多少趟。题面给出的代码雏形表明,大件和小件物品对车容量的占用不同,小件可能按某个比例折算成等效容量,因此需要先明确两种 truck 的容量、大小件的折算规则,以及每趟是否允许混装。明确这些信息后,就可以按每一趟优先塞入大件,再用剩余空间补小件,循环直到所有物品运完。