Skip to main content
removeu 76 caracteres do conteúdo
Fonte Link
def countSignals(frequencies, ranges):
    for i in range(len(ranges)):
       range_obj = range[range(ranges[i][0]i[0], ranges[i][1]i[1] + 1)
      for ranges[i]i =in range_objranges]
    return sum(1 if all(f in r for r in ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
def countSignals(frequencies, ranges):
    for i in range(len(ranges)):
       range_obj = range(ranges[i][0], ranges[i][1] + 1)
       ranges[i] = range_obj
    return sum(1 if all(f in r for r in ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
def countSignals(frequencies, ranges):
    ranges = [range(i[0], i[1] + 1) for i in ranges]
    return sum(1 if all(f in r for r in ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
removeu 12 caracteres do conteúdo
Fonte Link
def countSignals(frequencies, ranges):
    new_ranges = []
    for i in range(len(ranges)):
       irange_obj = range(ranges[i][0], ranges[i][1] + 1)
       new_ranges.append(i)ranges[i] = range_obj
    return sum(1 if all(f in r for r in new_rangesranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
def countSignals(frequencies, ranges):
    new_ranges = []
    for i in range(len(ranges)):
       i = range(ranges[i][0], ranges[i][1] + 1)
       new_ranges.append(i)
    return sum(1 if all(f in r for r in new_ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
def countSignals(frequencies, ranges):
    for i in range(len(ranges)):
       range_obj = range(ranges[i][0], ranges[i][1] + 1)
       ranges[i] = range_obj
    return sum(1 if all(f in r for r in ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)
adicionou 953 caracteres ao conteúdo
Fonte Link

EDIT APÓS SUGESTÕES:

def countSignals(frequencies, ranges):
    new_ranges = []
    for i in range(len(ranges)):
       i = range(ranges[i][0], ranges[i][1] + 1)
       new_ranges.append(i)
    return sum(1 if all(f in r for r in new_ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)

Passei em 12/15 testes. Preciso otimizar mais... Não consigo alterar nada definido no método main, apenas consigo alterar a função countSignals.

EDIT APÓS SUGESTÕES:

def countSignals(frequencies, ranges):
    new_ranges = []
    for i in range(len(ranges)):
       i = range(ranges[i][0], ranges[i][1] + 1)
       new_ranges.append(i)
    return sum(1 if all(f in r for r in new_ranges) else 0 for f in frequencies)


if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)

Passei em 12/15 testes. Preciso otimizar mais... Não consigo alterar nada definido no método main, apenas consigo alterar a função countSignals.

título editado
Link
Carregando
Fonte Link
Carregando