文章

43

粉丝

24

获赞

293

访问

6.6k

头像
合并果子 题解:果宝机甲,归位!
P1544 中南大学机试题
发布于2025年2月27日 11:08
阅读数 122

#include<bits/stdc++.h> 
using namespace std;
int main(){
    int n;
    priority_queue<int,vector<int>,greater<int>>pq;//定义top元素为最小元素 
    while(cin>>n){
        for(int i=0;i<n;i++){
            int temp;
            cin>>temp;
            pq.push(temp);
        }
        int ans=0; 
        while(pq.size()!=1){//当只剩一堆的时候就不用搬了 
            int newapp=0;//新的小苹果嘟嘟嘟 
            newapp+=pq.top();
            pq.pop();
            newa...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发