土肥圆哥哥:大小差肯定只能是大小堆 #include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
priority_queue<int>bigheap;
priority_queue<int, vector<int>, greater<int>> smallheap;
for (int i = 0; i < N; i++)
{
int tem;
cin >> tem;
bigheap.push(tem);
smallheap.push(tem);
}
while (bigheap.size() != 1)
{
int a = bigheap.top();
bigheap.pop();
int b = bigheap.top();
bigheap.pop();
bigheap.push(a * b + 1);
}
int min = bigheap.top();
while (smallheap.size() != 1)
{
int a = smallheap.top();
smallheap.pop();
int b = smallheap.top();
smallheap.pop();
smallheap.push(a * b + 1);
}
int max = smallheap.top();
cout << max - min<<endl;
return 0;
}