Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
166992 | D班-柯铭皓 | 紧急集合 | C++ | 通过 | 100 | 5 MS | 356 KB | 347 | 2024-08-19 15:45:39 |
#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int> > q; int n,ans; signed main(){ cin>>n; for(int i=1;i<=n;i++) { int x; cin>>x; q.push(x); } while(q.size()>1) { int x=q.top(); q.pop(); int y=q.top(); q.pop(); ans+=x+y; q.push(x+y); } cout<<ans; return 0; }