#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int T;
    scanf("%d",&T);
    for(int i=0; i<T; i++)
    {
        int A[20005]={};
        int B[20005]={};
        int N,M;
        scanf("%d %d",&N,&M);
        for(int j=0; j<N; j++)
        {
            scanf("%d",&A[j]);
        }
        for(int j=0; j<M; j++)
        {
            scanf("%d",&B[j]);
        }
        sort(B,B+M);
        int ep=0;
        for(int j=0; j<N; j++)
        {
            ep+=lower_bound(B,B+M,A[j])-B;
        }
        printf("%d\n",ep);
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: