#include #include void swap(int *a, int *b); void insert(int value, int *heap, int* size); void delete(int *heap, int* size); int main(){ int N; scanf("%d",&N); int *heap = (int*)malloc(sizeof(int)*(N+1)); int heap_size = 0; while(N--){ int op; scanf("%d",&op); if(op==0) delete(heap, &heap_size); else insert(op, heap, &heap_size); } free(heap); return 0; } void swap(int *a, int *b){ int temp = *a; *a = *b; *b = temp; } void insert(int value, int *heap, int* size){ heap[++(*size)] = value; int current = *size; while(current != 1){ if((abs(heap[current]) < abs(heap[current/2]) || (abs(heap[current]) == abs(heap[current/2]) && heap[current]