fork download
  1. #include <bits/stdc++.h>
  2. using namespace std ;
  3.  
  4. int main()
  5. {
  6. int a , b ;
  7. scanf("%d %d" , &a , &b) ;
  8. set <int> s ;
  9. for(int i = 0 ; i < a ; i++)
  10. {
  11. int P ;
  12. scanf("%d" , &P) ;
  13. s.insert(P) ;
  14. }
  15. set <int> :: iterator it ;
  16. for(int i = 0 ; i < b ; i++)
  17. {
  18. int H ;
  19. scanf("%d" , &H) ;
  20. printf("%d " , *s.find(H)) ;
  21. }
  22. return 0 ;
  23. }
Success #stdin #stdout 0s 15232KB
stdin
5 4
1 3 5 7 9
6 4 2 8
stdout
5 5 5 5