Advertisement
Guest User

4a

a guest
Dec 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. // f88146 Mihaela Mihova
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. long cntEx, n, m, k, num;
  13. vector<int> v;
  14. vector<int> vCnt;
  15.  
  16. cin>>cntEx;
  17.  
  18. for(int i=0; i<cntEx; i++)
  19. {
  20. cin>>n>>m;
  21.  
  22. for(int j=0; j<m; j++)
  23. {
  24. cin>>k;
  25. vCnt.push_back(k-1);
  26. }
  27.  
  28. for(int j=0; j<n; j++)
  29. {
  30. cin>>num;
  31. v.push_back(num);
  32. }
  33. sort (v.begin(), v.end());
  34.  
  35. for(int j=0; j<m; j++)
  36. {
  37. cout<<v[vCnt[j]]<<endl;
  38. }
  39.  
  40. v.clear();
  41. vCnt.clear();
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement