SHARE
TWEET

Untitled

a guest Mar 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <vector>
  4. #include <set>
  5. #include <map>
  6. #include <math.h>
  7. #include <algorithm>
  8. #include <queue>
  9. #include <string>
  10. #include <unordered_set>
  11. #include <deque>
  12. #include <unordered_map>
  13. #include <assert.h>
  14. #include <iomanip>
  15. #include <stack>
  16. #include <bitset>
  17.  
  18. using namespace std;
  19.  
  20. typedef long long ll;
  21. typedef long double ld;
  22. typedef unsigned long long ull;
  23. #define all(x) x.begin(), x.end()
  24. #define pb push_back
  25.  
  26. void io() {
  27. #ifdef DEBUG
  28.     freopen("a.in", "r", stdin);
  29.     freopen("a.out", "w", stdout);
  30. #endif
  31.     cin.tie(NULL);
  32.     cout.tie(NULL);
  33.     ios_base::sync_with_stdio(false);
  34. }
  35.  
  36.  
  37. signed main() {
  38.     io();
  39.     int n, k;
  40.     cin >> n >> k;
  41.     vector<pair<int, int>> v(n);
  42.     for (int i = 0; i < n; i++) {
  43.         cin >> v[i].first;
  44.         v[i].second = i;
  45.     }
  46.     sort(v.begin(), v.end());
  47.     int cnt = 1;
  48.     reverse(all(v));
  49.     vector<pair<int, int>> v1;
  50.     for (int i = 1; i < n; i++) {
  51.         if (v[i].first != v[i - 1].first) {
  52.             cnt++;
  53.             if (cnt > k) {
  54.                 for (int j = i; j < n; j++) {
  55.                     v1.push_back({ v[j].second, v[j].first });
  56.                 }
  57.                 break;
  58.             }
  59.         }
  60.     }
  61.     sort(v1.begin(), v1.end());
  62.     cout << v1.size() << endl;
  63.     for (int i = 0; i < v1.size(); i++)
  64.         cout << v1[i].second << ' ';
  65.     return 0;
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top