Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <deque>
#include <set>

using namespace std;


int main()
{
    //speedup;

        int n, m;
        cin >> n >> m;
        vector<int>a(n),k(m);


        for(int i = 0 ; i < n; i++){

            cin >> a[i];
        }

        for(int i = 0 ; i < m; i++){

            cin >> k[i];
        }

        sort(k.begin(),k.end());


        int r =0;
        for(int i = 0 ; i < m; i++){


            if(k[i] < a[n - 1]){

                for(int j = 0 ; j < n; j++)
                {
                    if(a[j] > k[i]){

                        swap(a[j], k[i]);
                        r++;
                    }
                }
                a.push_back(k[i]);
                n++;
            }
            else{
                break;
            }
        }

        cout<<r;

    return 0;
}
Copy
Insertion sort. No not that one IssamAbdoh
GNU G++17
5 ms
400 KB
Wrong Answer