Skip to content

Instantly share code, notes, and snippets.

@fredbr
Created May 2, 2018 22:31
Show Gist options
  • Save fredbr/1c1064618502c94256d4a26163d19698 to your computer and use it in GitHub Desktop.
Save fredbr/1c1064618502c94256d4a26163d19698 to your computer and use it in GitHub Desktop.
Bonecas
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int v[maxn];
int u[maxn];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> v[i], u[i] = v[i];
sort(u, u+n);
vector<int> res;
for (int i = 0; i < n; i++) if (v[i] != u[i]) res.push_back(v[i]);
sort(res.begin(), res.end());
cout << res.size() << "\n";
for (int i : res) cout << i << " ";
cout << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment