前言
传送门
正文
参考题解
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std
;
int main(){
priority_queue
<int,vector
<int>,greater
<int>> q
;
int n
,res
=0;
cin
>>n
;
for(int i
,seg
;i
<n
;i
++){
cin
>>seg
;
q
.push(seg
);
}
while(q
.size()!=1){
int a
,b
;
a
=q
.top(),q
.pop();
b
=q
.top(),q
.pop();
res
=a
+b
>>1;
q
.push(res
);
}
cout
<<res
<<endl
;
return 0;
}
转载请注明原文地址:https://tech.qufami.com/read-26184.html