只对了一个点,求助

P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

**蒟蒻**建议直接用STL的priority_queue<int,vector<int>,greater<int> >q;
by Alan_M_Turing @ 2020-07-28 12:27:23


``` #include<cstdio> #include<iostream> #include<queue> using namespace std; priority_queue <int,vector<int>,greater<int> > que; int main() { int n,x,js=0; scanf("%d",&n); for(int i=0;i<n;++i) { scanf("%d",&x); que.push(x); } int ans,tmp; for(int j=1;j<n;++j) { tmp=que.top(); ans+=que.top(); que.pop(); tmp+=que.top(); ans+=que.top(); que.pop(); que.push(tmp); } printf("%d",ans); return 0; } ```
by lskksl @ 2020-08-22 10:38:38


|