优先队列解法
2026-02-09 18:17:31
发布于:陕西
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
priority_queue<int,vector<int>,greater<int> > q;
for(int i=1;i<=n;i++){
int t;cin>>t;
q.push(t);
}
for(int i=1;i<=m;i++){
int t;cin>>t;
q.push(t);
}
while(!q.empty()){
cout<<q.top()<<" ";
q.pop();
}
return 0;
}
这里空空如也







有帮助,赞一个