Source Code
#include<iostream>

using namespace std;

int main(){
	int n,k;
	cin>>n>>k;

	int freq[10001]={0};

	int number;
	int counter=0;
	for(int i=0;i<n;i++){
		cin>>number;
		
		if(freq[number]==0){
			counter++;
		}

		freq[number]++;


	}	

	// cout<<counter<<endl;

	int ki;
	int ans=0;
	for(int i=0;i<k;i++){
		cin>>ki;

		int arr[counter];
		int z = 0;
		for(int j=0;j<10001;j++){
			if(freq[j]!=0){
				arr[z]=j;
				z++;
			}
		}
		if(ki>=arr[counter-1]){
			// no replace
			continue;
		}
		else{
			int num_of_larger = 0;
			for(int i=0;i<counter;i++){
				if(arr[i]>ki){
					num_of_larger++;	
				}

			}
			// cout<<num_of_larger - 1<<endl;
			ans+=num_of_larger;
		}

		if(freq[ki]==0){
			counter++;
		}

		freq[ki]++;
	}


cout<<ans<<endl;
}

Copy
Insertion sort. No not that one Rimawi
GNU G++17
86 ms
748 KB
Wrong Answer