/**
 * You are a civil engineer working on a project to determine the maximum load a bridge can withstand.
 * The bridge is rectangular with a length and width provided as input arguments.
 * A list of truck weights is also provided as input.
 * Your task is to write a function that calculates the maximum load the bridge can hold without collapsing.
 * If a truck's weight exceeds the bridge's maximum load, it should continue to the next truck without affecting the calculations.
 *
 * @param bridgeLength The length of the bridge.
 * @param bridgeWidth The width of the bridge.
 * @param truckWeights A list of truck weights.
 * @return The maximum load the bridge can hold without collapsing.
 */
fun maxBridgeLoad(bridgeLength: Int, bridgeWidth: Int, truckWeights: List<Int>): Int {

    var maxLoad = 0

    for (truckWeight in truckWeights) {
        if (truckWeight > (bridgeLength * bridgeWidth) - maxLoad) {
            continue
        }

        if (truckWeight > maxLoad) {
            maxLoad = truckWeight
        }
    }

    return maxLoad
}
/**
 * You are a civil engineer working on a project to determine the maximum load a bridge can withstand.
 * The bridge is rectangular with a length and width provided as input arguments.
 * A list of truck weights is also provided as input.
 * Your task is to write a function that calculates the maximum load the bridge can hold without collapsing.
 * If a truck's weight exceeds the bridge's maximum load, it should continue to the next truck without affecting the calculations.
 *
 * @param bridgeLength The length of the bridge.
 * @param bridgeWidth The width of the bridge.
 * @param truckWeights A list of truck weights.
 * @return The maximum load the bridge can hold without collapsing.
 */
fun maxBridgeLoad(bridgeLength: Int, bridgeWidth: Int, truckWeights: List<Int>): Int {
/**
 * You are a civil engineer working on a project to determine the maximum load a bridge can withstand.
 * The bridge is rectangular with a length and width provided as input arguments.
 * A list of truck weights is also provided as input.
 * Your task is to write a function that calculates the maximum load the bridge can hold without collapsing.
 * If a truck's weight exceeds the bridge's maximum load, it should continue to the next truck without affecting the calculations.
 *
 * @param bridgeLength The length of the bridge.
 * @param bridgeWidth The width of the bridge.
 * @param truckWeights A list of truck weights.
 * @return The maximum load the bridge can hold without collapsing.
 */
fun maxBridgeLoad(bridgeLength: Int, bridgeWidth: Int, truckWeights: List<Int>): Int {

    var maxLoad = 0

    for (truckWeight in truckWeights) {
        if (truckWeight > (bridgeLength * bridgeWidth) - maxLoad) {
            continue
        }

        if (truckWeight > maxLoad) {
            maxLoad = truckWeight
        }
    }

    return maxLoad
}