`while(rt>1&&heap[rt]>heap[rt>>1]){` should be `while(rt>1&&heap[rt]<heap[rt>>1]){`
and ...
why you only read n-1 numbers.
by ksun48 @ 2023-08-16 15:16:05
```cpp
for(int i=1;i<n;i++)
{
heap_size++;
cin>>heap[heap_size];
shift_up(heap_size);
}
```
should be
```cpp
for(int i=1;i<=n;i++)
{
heap_size++;
cin>>heap[heap_size];
shift_up(heap_size);
}
```
by ksun48 @ 2023-08-16 15:16:28
@[liyirong567](/user/955954)
by ksun48 @ 2023-08-16 15:16:36
Thank you!
by shooting__star @ 2023-08-16 17:32:00