Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- class Meci {
- public:
- Meci() : cota("0"), index(0) {}
- Meci(string const& c, int const& i) : cota(c), index(i) {}
- bool operator < (Meci const& M) const {
- if (cota.size() != M.cota.size())
- return cota.size() > M.cota.size();
- if (cota != M.cota)
- return cota > M.cota;
- return index < M.index;
- }
- inline int GetIndex() const {
- return index;
- }
- private:
- string cota;
- int index;
- };
- int n, k;
- string cota;
- vector<Meci> v;
- vector<int> res;
- int main() {
- ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
- cin >> n >> k;
- for (int i = 1; i <= n; ++i) {
- cin >> cota;
- v.emplace_back(cota, i);
- }
- sort(v.begin(), v.end());
- for (int i = 0; i < k; ++i)
- res.emplace_back(v[i].GetIndex());
- sort(res.begin(), res.end());
- for (int const& i : res)
- cout << i << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement