1 条题解

  • 0
    @ 2022-12-6 21:27:29

    您的测试点太水了(

    #include <bits/stdc++.h>
    using namespace std;
    
    
    int main()
    {
        priority_queue<int,vector<int>,greater<int> > q;
        int n;
        int ans = 0;
        cin >> n;
        while(n--)
        {
            int x;
            cin >> x;
            q.push(x);
        }
        while(q.size()>=2)
        {
            int a = q.top();
            q.pop();
            int b = q.top();
            q.pop();
            ans+=(a+b);
            q.push(a+b);
        }
        cout << ans;
        return 0;
    }
    
    
    • 1

    信息

    ID
    335
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    30
    已通过
    13
    上传者