Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- vector<int> a = {8, 5, 10, 6, 10, 7, 8, 11};
- sort(a.begin(), a.end(), [](int i, int j){
- if (i % 2 == j % 2) {
- return i < j;
- } else {
- return i % 2 > j % 2;
- }
- });
- for (auto element : a) {
- cout << element << " ";
- }
- cout << '\n';
- int cur_cnt = 0;
- vector<int> ans;
- for (int i = 0; i < a.size(); ++i) {
- int j = i;
- while (j < a.size() - 1 and a[j + 1] == a[j]) {
- ++j;
- }
- if (j - i + 1 > cur_cnt) {
- cur_cnt = j - i + 1;
- ans.clear();
- ans = {a[j]};
- } else if (j - i + 1 == cur_cnt) {
- ans.push_back(a[j]);
- }
- }
- for (auto element : ans) {
- cout << element << " ";
- }
- cout << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement