Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
136540 刘嘉乐 紧急集合 C++ 通过 100 3 MS 360 KB 368 2024-03-09 10:18:55

Tests(10/10):


#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int> > pq; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ int x; cin>>x; pq.push(x); } int cnt = 0; while(pq.size()>1){ int a = pq.top(); pq.pop(); int b = pq.top(); pq.pop(); pq.push(a+b); cnt+=a+b; } cout<<cnt<<'\n'; return 0; }


测评信息: