Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
134448 | Fess | 紧急集合 | C++ | 通过 | 100 | 3 MS | 360 KB | 312 | 2024-03-02 15:54:54 |
#include<bits/stdc++.h> using namespace std; int n,t,ans; priority_queue<int,vector<int>,greater<int> >q; int main() { cin>>n; for(int i=1;i<=n;i++) cin>>t,q.push(t); while(q.size()>1) { int a,b; a=q.top(); q.pop(); b=q.top(); q.pop(); q.push(a+b); ans+=a+b; } cout<<ans; }