Advertisement
a53

pariuri2

a53
Nov 24th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. class Meci {
  4. public:
  5. Meci() : cota("0"), index(0) {}
  6. Meci(string const& c, int const& i) : cota(c), index(i) {}
  7. bool operator < (Meci const& M) const {
  8. if (cota.size() != M.cota.size())
  9. return cota.size() > M.cota.size();
  10. if (cota != M.cota)
  11. return cota > M.cota;
  12. return index < M.index;
  13. }
  14. inline int GetIndex() const {
  15. return index;
  16. }
  17. private:
  18. string cota;
  19. int index;
  20. };
  21. int n, k;
  22. string cota;
  23. vector<Meci> v;
  24. vector<int> res;
  25. int main() {
  26. ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  27. cin >> n >> k;
  28. for (int i = 1; i <= n; ++i) {
  29. cin >> cota;
  30. v.emplace_back(cota, i);
  31. }
  32. sort(v.begin(), v.end());
  33. for (int i = 0; i < k; ++i)
  34. res.emplace_back(v[i].GetIndex());
  35. sort(res.begin(), res.end());
  36. for (int const& i : res)
  37. cout << i << ' ';
  38. return 0;
  39. }
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement