Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

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

$
0
0

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;
    } 


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>