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.
#include <iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, k; vector<int> selves1, selves2;int skew; int max1,max2,maxall;
vector<int>::iterator bigger,smaller;
cin>>n;
cin>>k;
for(int i=0;i<n;i++){
cin>>skew;