Advertisement
sherry_ahmos

Reading

Jul 16th, 2022
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. ll n, m;
  2.     cin >> n >> m;
  3.     vector<int> v1(n);
  4.     vector<int> v2(n);
  5.     for (int i = 0; i < n; i++)
  6.     {
  7.         cin >> v1[i];
  8.         v2[i] = v1[i];
  9.     }
  10.     sort(v1.begin(), v1.end(), greater<int>());
  11.     cout << v1[m - 1] << nl;
  12.     auto it1 = v1.begin() + m;
  13.     auto it2 = v1.end();
  14.     v1.erase(it1, it2);
  15.     for (int i = 0; i < n; i++)
  16.     {
  17.         for (int j = 0; j < v1.size(); j++)
  18.         {
  19.             if (v2[i] == v1[j])
  20.             {
  21.                 cout << i + 1 << " ";
  22.                 auto it3 = v1.begin() + j;
  23.                 v1.erase(it3);
  24.                 break;
  25.             }
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement