Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <unordered_map>
- using namespace std;
- #define ll long long
- #define nl endl
- #define cy cout << "Yes\n"
- #define cn cout << "No\n"
- #define sz s.size()
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- bool comp(const pair<int, int> &a, const pair<int, int> &b)
- {
- if (a.first == b.first)
- {
- return a.second > b.second;
- }
- return a.first > b.first;
- }
- int main()
- {
- sherry();
- ll n, k;
- cin >> n >> k;
- vector<int> v(2 * n + 1);
- vector<pair<int, int>> v2(2 * n + 1);
- for (int i = 0; i < v.size(); i++)
- {
- cin >> v[i];
- v2[i].first = v[i];
- v2[i].second = i;
- }
- sort(v2.begin(), v2.end(), comp);
- for (int i = 0; i < k; i++)
- {
- v[v2[i].second]--;
- }
- for (auto &i : v)
- cout << i << " ";
- }
Add Comment
Please, Sign In to add comment