-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add files via upload #132
base: Odintsova_Anastasia
Are you sure you want to change the base?
Add files via upload #132
Conversation
Воспользовалась помощью Кирилла Шестакова, если что
it[v] = val | ||
return | ||
middle = (r+l)//2 | ||
if indx < middle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мы сравниваем индекс с серединой, если условие выполняется, то идем в левую часть дерева (т.е. именно там будем менять текущее значение с индексом indx на значение val). А изменение значения будет происходить, когда мы дойдем до листа (код 97-99).
s = get_sum(0, 0, n, it, l-1, r) | ||
if s >= k and l > 1: #условие проверки на количество нулей | ||
res.append(get_null(0, 0, n, it, k+get_sum(0, 0, n, it, 0, l-1))) | ||
elif s >= k and l == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что значит l > 1 и l == 1?
print(*heap) | ||
result.append(extract(heap)) #здесь добавляем в конец результата значение. Я пробовала поменять на get_max() - вывод неправильный получился. Подскажите, как поменять на get_max() | ||
result.reverse() | ||
print(*result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i in range(N):
print(*heap)
result.append(get_max(heap))
extract(heap)
print(*result[::-1])
heap[0], heap[-1] = heap[-1], heap[0] | ||
a = heap.pop() | ||
shift_down(0, heap) | ||
return a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def extract(heap):
heap[0], heap[-1] = heap[-1], heap[0]
heap.pop()
shift_down(0, heap)
No description provided.