
0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
土肥圆哥哥:大小差肯定只能是大小堆 #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;
}

0 点赞 评论 收藏
分享
2019-08-25 21:12
东南大学 Java cysilver:我看到第6条就觉得怪怪的,纠正楼主,已经有人给出解答了
https://zhuanlan.zhihu.com/p/25028045
0 点赞 评论 收藏
分享
benefitfin...:大佬 什么岗位

0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
当当当荡:第五行,数组长度大到一定长度就会溢出。 一般都是同left+((right-left)>>1)来做的

0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: