<var id="ltzjf"></var><progress id="ltzjf"></progress><cite id="ltzjf"><video id="ltzjf"></video></cite>
<menuitem id="ltzjf"><strike id="ltzjf"></strike></menuitem>
<cite id="ltzjf"><video id="ltzjf"><menuitem id="ltzjf"></menuitem></video></cite>
<var id="ltzjf"><strike id="ltzjf"></strike></var>
<cite id="ltzjf"></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><strike id="ltzjf"></strike></cite>
<cite id="ltzjf"><span id="ltzjf"></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"><video id="ltzjf"></video></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><span id="ltzjf"><menuitem id="ltzjf"></menuitem></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"></cite>
Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA到死的看這里,講兩個坑點,貼一個AC代碼

Posted by algoriiiiithm at 2020-11-09 20:12:19 on Problem 3253
1.結果要用long long類型
2.不要printf("%d\n", ans);數據類型是long long和%d不匹配的,改成cout就可以

用priority_queue的代碼:

#include <queue>
#include <vector>
#include <functional>
#include <iostream>
using namespace std;

int main(void)
{
	int n, i;
	long long ans = 0;
	priority_queue<int, vector<int>, greater<int>> pQ;
	cin >> n;
	for(i = 0; i < n; i++){
		int a;
		cin >> a;
		pQ.push(a);
	}
	while(pQ.size() >= 2){
		int x, y;
		x = pQ.top();
		pQ.pop();
		y = pQ.top();
		pQ.pop();
		ans += (x + y);
		pQ.push(x + y);
	}
	cout << ans << endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator

欧美免费全部免费观看_日本免费高清在线视频_欧美色视频日本片免费
<var id="ltzjf"></var><progress id="ltzjf"></progress><cite id="ltzjf"><video id="ltzjf"></video></cite>
<menuitem id="ltzjf"><strike id="ltzjf"></strike></menuitem>
<cite id="ltzjf"><video id="ltzjf"><menuitem id="ltzjf"></menuitem></video></cite>
<var id="ltzjf"><strike id="ltzjf"></strike></var>
<cite id="ltzjf"></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><strike id="ltzjf"></strike></cite>
<cite id="ltzjf"><span id="ltzjf"></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"><video id="ltzjf"></video></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><span id="ltzjf"><menuitem id="ltzjf"></menuitem></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"></cite>