Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits//stdc++.h>
- #define RIP(i,a,b) for(int i = a; i < b; i++)
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n;
- cin >> n;
- vector<int> a;
- vector< pair<int, int> > b;
- RIP(i,0,n)
- {
- int x;
- cin >> x;
- a.push_back(x);
- int l = 0, r = b.size();
- while(r - l > 1)
- {
- int m = (l + r)/2;
- if(b[m].first > x)
- r = m;
- else
- l = m;
- }
- if(b[l].first == x)
- b[l].second += 1;
- else if(b[r].first == x)
- b[r].second += 1;
- else
- b.insert(b.begin() + l, {x, 1});
- }
- int mx = 0, mxn;
- for(auto u: b)
- {
- if(u.second > mx)
- {
- mx = u.second;
- mxn = u.first;
- }
- }
- RIP(i,0,n)
- {
- if(a[i] != mxn)
- cout << a[i];
- }
- RIP(i,0,mx)
- cout << mxn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement