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

count of maximum | giving wrong answer despite of several fruitfull test cases

$
0
0

i don't understand why my code is giving wrong answer it is producing correct results for all test cases provided at question page and in forums.. please help

#include <stdio.h>
int main()
{
    int i,j,A[10000],Q[10000],n,t,k,c,maxc;
    scanf("%d", &t);
    for (i = 0; i < t; ++i)
    {
        for (j = 0; j < 10000; ++j)
        {
            A[j]=0;
            Q[j]=0;
        }
        scanf("%d",&n);
        for (j = 0; j < n; ++j)
        {
            scanf("%d", &A[j]);
            Q[A[j]]++;
        }
        k=10000;
        c=0;
        while(k--)
        {
            if (Q[k]>0&&c<=Q[k])
            {
                    c=Q[k];
                    maxc=k;
                }
            }
            printf("%d %d\n", maxc, c);
        }

        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>