#include #include #include using namespace std; struct Heap { int* a; int size; Heap( int* x , int sz ) { size = sz; a = new int[sz + 1]; for (int i=1 ; i<=sz ; i++) a[i] = x[i]; } void BuildHeap() { int p = size / 2; for ( int i=p ; i>=1 ; i--) Heapify(i); } void Heapify(int i) { while (true) { int l = i*2; int r = i*2+1; int g = i; // farz konim kuchiktarin adad pedare if ( l<=size && a[l] pas nemishe bishtar az in edame dad break; } } /*void Heapify(int p) { while (true) { int l = p*2; int r = p*2 + 1; if (l > size && r > size) break; int vl , vr; if ( r > size ) { if ( a[l] < a[p] ) { swap(a[l] , a[p]); p = l; } else break; } else { int v = a[l]=0 && k<=size ; i--,j++) { int c = t[j]; // Num of numbers in current row int out_space = t[i]; // Space of left side int in_space = (t[i+1]-1); // Space between numbers cout<