优先队列
1 #include<stdio.h> 2 #include<functional> 3 #include<queue> 4 using namespace std; 5 int main() 6 { 7 priority_queue<int,vector<int>,greater<int> >q; 8 int temp; 9 int n,m; 10 while(scanf("%d %d",&n,&m)!=EOF) 11 { 12 for(int i=0;i<n+m;i++) 13 { 14 scanf("%d",&temp); 15 q.push(temp); 16 } 17 temp=q.top(); 18 printf("%d",temp); 19 while(!q.empty()) 20 { 21 if(temp==q.top()) q.pop(); 22 else 23 { 24 temp=q.top(); 25 printf(" %d",temp); 26 } 27 } 28 printf(" "); 29 } 30 }