6分,就过了数据点1
查看原帖
6分,就过了数据点1
1189340
aishiteru_mitsu_ha楼主2024/5/25 19:16

别问为什么用优先队列,懒

#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> >p;
int n;
string s;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        int cnt=0;
        for(int j=0;j<s.size();j++){
            if(s[j]>='0'&&s[j]<='9'){
                while(s[j]>='0'&&s[j]<='9'){
                    cnt=cnt*10+s[j]-'0';
                    j++;
                }
                p.push(cnt);
                cnt=0;
            }
        }
    }
    while(!p.empty()){
        cout<<p.top()<<endl;
        p.pop();
    }
    return 0;
}
2024/5/25 19:16
加载中...