Advertisement
sherry_ahmos

R. Mountain Scenery

Jul 25th, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <string>
  5. #include <queue>
  6. #include <map>
  7. #include <set>
  8. #include <string>
  9. #include <algorithm>
  10. #include <cmath>
  11. #include <unordered_map>
  12.  
  13. using namespace std;
  14. #define ll long long
  15. #define nl endl
  16. #define cy cout << "Yes\n"
  17. #define cn cout << "No\n"
  18. #define sz s.size()
  19.  
  20. void sherry()
  21. {
  22.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  23. #ifndef ONLINE_JUDGE
  24.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  25. #endif
  26. }
  27. bool comp(const pair<int, int> &a, const pair<int, int> &b)
  28. {
  29.     if (a.first == b.first)
  30.     {
  31.         return a.second > b.second;
  32.     }
  33.     return a.first > b.first;
  34. }
  35. int main()
  36. {
  37.     sherry();
  38.     ll n, k;
  39.     cin >> n >> k;
  40.     vector<int> v(2 * n + 1);
  41.     vector<pair<int, int>> v2(2 * n + 1);
  42.     for (int i = 0; i < v.size(); i++)
  43.     {
  44.         cin >> v[i];
  45.         v2[i].first = v[i];
  46.         v2[i].second = i;
  47.     }
  48.     sort(v2.begin(), v2.end(), comp);
  49.     for (int i = 0; i < k; i++)
  50.     {
  51.         v[v2[i].second]--;
  52.     }
  53.     for (auto &i : v)
  54.         cout << i << " ";
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement