30pts求助
查看原帖
30pts求助
865625
KobeBeanBryantCox楼主2023/7/21 14:25

rt 30pts

#include<bits/stdc++.h>
#define Code using
#define by namespace
#define wjb std
Code by wjb;
int n,a,ans=0;
priority_queue<int,vector<int>,greater<int> >q;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a,q.push(a);
	while(q.size()>=2)
	{
		int x=q.top();
		q.pop();
		int y=q.top();
		q.pop();
		ans+=x+y,q.push(x+y);
	}
	cout<<ans;
	return 0;
}

先不说TLE,为什么会WA,原题可以过的啊

开long long也WA

2023/7/21 14:25
加载中...