Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
134350 方文轩 紧急集合 C++ 通过 100 2 MS 488 KB 386 2024-03-02 15:40:56

Tests(10/10):


#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ ios::sync_with_stdio(0); cin.tie(0); priority_queue<int,vector<int>, greater<int>>q; int n; cin >> n; for(int i = 1;i <= n;i++){ int x; cin >> x; q.push(x); } int ans = 0; for(int i = 1;i < n;i++){ int a = q.top(); q.pop(); int b = q.top(); q.pop(); ans+=a+b; q.push(a+b); } cout << ans; return 0; }


测评信息: