Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // f88146 Mihaela Mihova
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- long cntEx, n, m, k, num;
- vector<int> v;
- vector<int> vCnt;
- cin>>cntEx;
- for(int i=0; i<cntEx; i++)
- {
- cin>>n>>m;
- for(int j=0; j<m; j++)
- {
- cin>>k;
- vCnt.push_back(k-1);
- }
- for(int j=0; j<n; j++)
- {
- cin>>num;
- v.push_back(num);
- }
- sort (v.begin(), v.end());
- for(int j=0; j<m; j++)
- {
- cout<<v[vCnt[j]]<<endl;
- }
- v.clear();
- vCnt.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement