COOLING problem | why am i getting wrong answer for COOLING problem?

my program is generating correct answer for the test cases and the logic is also good, but why am i getting wrong answer for my code…


    #include <stdio.h>
    int main()
    {
    	int ttt,i,nnn,k,j,arr2[31],arr1[31],tmp,count;
    	scanf("%d", &ttt);
    	for (i = 0; i < ttt; ++i)
    	{
    		count=0;
    		scanf("%d", &nnn);
    		for (j = 0; j < nnn; ++j)
    			scanf("%d", &arr1[j]);
    		for (j = 0; j < nnn; ++j)
    			scanf("%d", &arr2[j]);
    		for (j = 0; j < nnn; ++j)
    			for (k = j; k < nnn; ++k)
    				if (arr1[j]>arr1[k])
    				{
    					tmp=arr1[j];
    					arr1[j]=arr1[k];
    					arr1[k]=tmp;
    				}
    				if (arr2[j]>arr2[k])
    				{
    					tmp=arr2[j];
    					arr2[j]=arr2[k];
    					arr2[k]=tmp;
    				}
    		k=-1;
    		for (j = 0; j < nnn; ++j)
    			for (k = k+1; k < nnn; ++k)
    				if (arr1[j]<=arr2[k])
    				{
    					count++;
    					break;
    				}
    		printf("%d\n", count);
    	}
    	return 0;
    } 

Your code is not giving correct answer for the sample cases.
Also in your attempt to sort the two arrays you are making a silly mistake.

1 Like

my mistake! i shouldn’t have reduced that for loop braces

//