Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
193913 luckypet 紧急集合 C++ 通过 100 4 MS 352 KB 599 2025-05-27 15:25:04

Tests(10/10):


#include <iostream> #include <queue> #include <vector> using namespace std; int main() { int n; cin >> n; priority_queue<int, vector<int>, greater<int>> pq; for (int i = 0; i < n; ++i) { int a; cin >> a; pq.push(a); } int total_cost = 0; while (pq.size() > 1) { int a = pq.top(); pq.pop(); int b = pq.top(); pq.pop(); int cost = a + b; total_cost += cost; pq.push(cost); } cout << total_cost << endl; return 0; }


测评信息: