NewCodeTemplate

This commit is contained in:
e2hang
2025-12-16 20:36:27 +08:00
parent 684e35b210
commit 8253f2dcbc
26 changed files with 2547 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <queue>
using namespace std;
int main(){
priority_queue<int, vector<int>, greater<int>> pq;
int n;
cin >> n;
int tmp;
int sum = 0;
for(int i = 0; i < n; i++){
cin >> tmp;
sum += tmp;
pq.push(tmp);
}
long long ans = 0;
while(pq.size() > 1){
int x = pq.top(); pq.pop();
int y = pq.top(); pq.pop();
pq.push(x + y);
ans += (x + y);
}
cout << ans << endl;
return 0;
}