Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
168097 | B班---刘鸿晖 | 紧急集合 | C++ | 通过 | 100 | 4 MS | 356 KB | 319 | 2024-08-19 22:36:24 |
#include<bits/stdc++.h> using namespace std; long long n,i,x,y,ans; priority_queue<int,vector<int>,greater<int> > p; int main(){ cin>>n; for(i=1;i<=n;i++){ cin>>x; p.push(x); } while(p.size()!=1){ x=p.top();p.pop(); y=p.top();p.pop(); ans+=x+y; p.push(x+y); } cout<<ans; return 0; }