from typing import Dict
from typing import List


def fitness(state: Dict[int, List[int]]) -> float:
    """evaluate the fitness of a solution

    calculate the average gap of time between all processors

    :param state: the state to evaluate

    :return: the average gap
    """
    avg = sum([sum(state[i]) for i in range(len(state))])
    avg /= len(state)

    sums = [sum(state[i]) for i in range(len(state))]
    return sum(abs(avg - record) for record in sums)