def check_ranking(ranking, mtable):
    """
    Checks if the ranking is fair in respect to the mtable
    :param ranking:     The ranking to be checked (list of FairScoreDoc)
    :param mtable:      The mtable against to check (list of int)
    :return:            Returns whether the rankings satisfies the mtable
    """
    count_protected = 0
    if len(ranking) != len(mtable):
        raise ValueError(
            'Number of documents in ranking and mtable length must be equal!')
    for i, element in enumerate(ranking):
        count_protected += 1 if element.is_protected else 0
        if count_protected < mtable[i]:
            return False
    return True
