Hints for SRM 297, D2, 250-pointer (PackingParts)
James S. Plank
Sun Feb 16 14:03:09 EST 2014
The vectors are already sorted, so you should have two indices: i for parts and j for
boxes. Start them both at zero. Then you simply run through their steps:
- Try to match part i with box j.
- If part i is too big, keep incrementing j until either j is the
size of the box vector,
or the part fits into box j.
- If j is the size of the box vector, return i.
- If not, increment i and j.
- When i is as big as the parts vector, return i.