Exemplo n.º 1
0
    def _get_number_near_bolls(self) -> int:
        """кол-во мячей заброшенный в 2-ух очковой зоне"""
        lower = upper_bound(self._history, self._PENALTY_MARKER)
        if self._history[lower] == self._PENALTY_MARKER:
            return 0

        upper = upper_bound(self._history, self._near_end)
        if self._history[upper] <= self._near_end:
            return upper - lower + 1
        else:
            return upper - lower
Exemplo n.º 2
0
    def _get_number_penalty_bolls(self) -> int:
        """кол-во мячей заброшенных со штрафной"""
        upper = upper_bound(self._history, self._PENALTY_MARKER)

        if self._history[upper] == self._PENALTY_MARKER:
            return upper + 1
        else:
            return upper
Exemplo n.º 3
0
    def _get_number_far_bolls(self) -> int:
        """кол-во мячей заброшенный в 3-ех очковой зоне"""
        lower = upper_bound(self._history, self._near_end)

        if self._history[lower] <= self._near_end:
            return 0
        else:
            upper = len(self._history) - 1
            return upper - lower + 1
Exemplo n.º 4
0
from algoritms.binary_search import lower_bound
from algoritms.binary_search import upper_bound

if __name__ == "__main__":
    # N
    _ = input()
    array = [int(i) for i in input().strip().split()]
    array.sort()

    # M
    _ = input()
    requests = [int(i) for i in input().strip().split()]

    for request in requests:
        lb_index = lower_bound(array, request)
        ub_index = upper_bound(array, request)

        # если есть элемент > request
        if (array[lb_index] == request and
            array[ub_index] != request):
            number = ub_index - lb_index
            print(number)
        # если request - это максимум
        elif (array[lb_index] == request and
              array[ub_index] == request):
            number = ub_index - lb_index + 1
            print(number)
        # request нет в массиве
        else:
            print(0)