Can you please check my code too. It is failing in a few test cases. I sorted two vectors. Then found the one with the maximum overall.Took an iterator to it's beginning and another to the other's end.Then started swapping k times if the swaps are beneficial. Attaching my code herewith. Another problem I am facing is that, I am quite quick in finding an algorithm.But take way too long to write the code properly.
using namespace std;
int n, k; vector<int> selves1, selves2;int skew; int max1,max2,maxall;