// range heap example
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main () {
int ia[] = {10,20,30,5,15};
vector<int> ivec(ia,ia+5);
make_heap (ivec.begin(),ivec.end());
for (int i = 0; i < (int)ivec.size(); i++)
cout<<ivec[i]<<" ";
cout<<endl;
ivec.push_back(40);
push_heap(ivec.begin(), ivec.end());
for (int i = 0; i < (int)ivec.size(); i++)
cout<<ivec[i]<<" ";
cout<<endl;
cout<<"ivec.size() : "<<ivec.size()<<endl; //6
pop_heap(ivec.begin(), ivec.end());
cout<<"ivec.size() : "<<ivec.size()<<endl; //6
cout<<ivec.back()<<endl;
ivec.pop_back();
cout<<"ivec.size() : "<<ivec.size()<<endl; //5\
sort_heap(ivec.begin(), ivec.end());
for (int i = 0; i < (int)ivec.size(); i++)
cout<<ivec[i]<<" ";
cout<<endl;
return 0;
}