比赛 | 板子大赛 | 评测结果 | AAAAAAAAAA |
---|---|---|---|
题目名称 | 合并果子 | 最终得分 | 100 |
用户昵称 | Asher | 运行时间 | 0.086 s |
代码语言 | C++ | 内存使用 | 3.38 MiB |
提交时间 | 2025-01-22 14:34:15 | ||
#include <bits/stdc++.h> using namespace std; long long n, a, l, ans; priority_queue<int> pq; int main() { freopen("fruit.in", "r", stdin); freopen("fruit.out", "w", stdout); cin >> n; for(int i = 1;i <= n; i++) { cin >> a; pq.push(-a); } while(1) { ans += l; l = pq.top(); pq.pop(); if(pq.empty()) break; l += pq.top(); pq.pop(); pq.push(l); } cout << -ans; return 0; }