Advertisement
Josif_tepe

Untitled

Mar 18th, 2022
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, m;
  8.     cin >> n >> m;
  9.     string s;
  10.     cin >> s;
  11.     sort(s.rbegin(), s.rend());
  12.     int niza[m];
  13.     for(int i = 0; i < m; i++)
  14.     {
  15.         cin >> niza[i];
  16.     }
  17.     for(int i = 0; i < m; i++)
  18.     {
  19.         cout << s[niza[i]-1] << " ";
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement