// Problem #99 - Truck loading #include #include "bay.h" int main() { int Package; int Trucks = 0; LoadingDock Bay; cin >> Package; while (Package != -1) { if (! Bay.load(Package) ) // Load it if we can; if not, take action { if ( (Bay.totalCapacity(1) - Bay.spaceOccupied(1)) > (Bay.totalCapacity(2) - Bay.spaceOccupied(2)) ) { Bay.dismiss(2); } else { Bay.dismiss(1); } Trucks++; Bay.load(Package); // It must fit now!!! } cin >> Package; } if (Bay.spaceOccupied(1) > 0) { Trucks++; } if (Bay.spaceOccupied(2) > 0) { Trucks++; } cout << Trucks << " trucks used." << endl; return 0; }