/**
 * This function takes a list of times for each electrical task, a list of rates for each task,
 * and the maximum number of hours the electrician can work in a day. It calculates the total time
 * taken to complete all the tasks, considering the maximum working hours limit, and returns the result.
 */
fun calculateTotalTime(timeList: List<Int>, rateList: List<Int>, hoursLimit: Int): Int {

    var totalTime = 0
    var taskIndex = 0

    while (taskIndex < timeList.size) {
        if (totalTime + timeList[taskIndex] > hoursLimit) {
            totalTime += if (timeList[taskIndex] <= hoursLimit) timeList[taskIndex] * rateList[taskIndex] else 0
        } else {
            totalTime += timeList[taskIndex] * rateList[taskIndex]
        }
        taskIndex++
    }

    return totalTime
}
/**
 * This function takes a list of times for each electrical task, a list of rates for each task,
 * and the maximum number of hours the electrician can work in a day. It calculates the total time
 * taken to complete all the tasks, considering the maximum working hours limit, and returns the result.
 */
fun calculateTotalTime(timeList: List<Int>, rateList: List<Int>, hoursLimit: Int): Int {
/**
 * This function takes a list of times for each electrical task, a list of rates for each task,
 * and the maximum number of hours the electrician can work in a day. It calculates the total time
 * taken to complete all the tasks, considering the maximum working hours limit, and returns the result.
 */
fun calculateTotalTime(timeList: List<Int>, rateList: List<Int>, hoursLimit: Int): Int {

    var totalTime = 0
    var taskIndex = 0

    while (taskIndex < timeList.size) {
        if (totalTime + timeList[taskIndex] > hoursLimit) {
            totalTime += if (timeList[taskIndex] <= hoursLimit) timeList[taskIndex] * rateList[taskIndex] else 0
        } else {
            totalTime += timeList[taskIndex] * rateList[taskIndex]
        }
        taskIndex++
    }

    return totalTime
}