// GT_COUNT.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int GT_COUNT(int f[],int nf,int g[],int ng)
{
	int indexg=ng-1;
	int count=0;
	while(indexg>=0)
	{
		for(int i=0;i<nf;i++)
			if(f[i]>g[indexg])
			{
				count+=(nf-i);
				indexg--;
				break;
			}
	}

	return count;

}


int gT_COUNT(int f[],int nf,int g[],int ng)
{
	int indexg=ng-1;
	int count=0;

	int startI=nf-1;
	int i;
	while(indexg>=0)
	{
		for(i=startI;i>=0;i--)
			if(f[i]<=g[indexg])
			{
				count+=(nf-i-1);
				indexg--;
				startI=i;
				break;
			}
	}

	return count;

}
int main(int argc, char* argv[])
{
	int f[]={1,3,5,7,9};
	int g[]={2,3,4,7,8};
	int nf=sizeof(f)/sizeof(int);
	int ng=sizeof(g)/sizeof(int);

	int GT_COUNT_=GT_COUNT(f, nf,g,ng);
	printf("GT_COUNT_=%d\n",GT_COUNT_);

	int gT_COUNT_=gT_COUNT(f, nf,g,ng);
	printf("gT_COUNT_=%d\n",gT_COUNT_);

	return 0;
}