![在这里插入图片描述](https://img-blog.csdnimg.cn/20200816222515695.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Jid3FzYg==,size_16,color_FFFFFF,t_70#pic_center)
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_map>
#include<cmath>
using namespace std;
const int maxn = 1001;
int n; vector<int>v;int a[maxn];
void dfs(int index)
{
if (index * 2 > n&& index * 2 + 1 > n)
{
if (index <= n)
{
for (int i = 0; i < v.size(); i++)
{
cout << v[i];
if (i != v.size() - 1) cout << " ";
else cout << endl;
}
}
}
else
{
v.push_back(a[index * 2 + 1]);
dfs(index * 2 + 1);
v.pop_back();
v.push_back(a[index * 2]);
dfs(index * 2);
v.pop_back();
}
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
int maxh = 1, minh = 1;
for (int i = 2; i <= n; i++)
{
if (a[i] > a[i / 2]) maxh = 0;
if (a[i] < a[i / 2]) minh = 0;
}
v.push_back(a[1]);
dfs(1);
if (maxh)
{
cout << "Max Heap";
}
else if (minh)
{
cout << "Min Heap";
}
else
{
cout << "Not Heap";
}
}