Created
October 13, 2016 02:55
-
-
Save vumbumy/4fca77ed3102b8781b5fbfea0514d00d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma warning(disable:4996) | |
| #include <iostream> | |
| #include <unordered_map> | |
| #include <vector> | |
| #include <algorithm> | |
| #include <stdio.h> | |
| using namespace std; | |
| bool A(const pair<int, pair<int,int> >& l, const pair<int, pair<int, int> >& r) { | |
| if (l.second.first == r.second.first) | |
| return l.second.second > r.second.second; | |
| return l.second.first > r.second.first; | |
| } | |
| int main() | |
| { | |
| unordered_map<int, pair<int,int>> m; | |
| int t, n; cin >> t >> n; | |
| while (t--) | |
| { | |
| cin >> n; | |
| m[n].first++; | |
| m[n].second = max(m[n].second,t); | |
| } | |
| vector<pair<int, pair<int,int> > > v(m.begin(), m.end()); | |
| sort(v.begin(), v.end(), &A); | |
| for (auto it : v) { | |
| for (int i = 0; i < it.second.first; i++) | |
| cout << it.first << " "; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment