Problem Code: STUDVOTE

#include <stdio.h>

int main(void) {
    int t;
    scanf("%d\n",&t);
    for (int i=0;i<t;i++)
    {
        int n,k,cnt;
        int max=0;
        scanf("%d %d\n",&n,&k);
        int arr[n];
        for (int j=0;j<n;j++){
            scanf("%d ",&arr[j]);
        }
        for (int j=1;j<=n;j++){
            cnt=0;
            for (int k=0;k<n;k++){
                if (arr[k]!=k+1){
                    if (arr[k]==j) cnt++;
                }
            }
            if (cnt>=k) max++;
        }
        printf("%d\n",max);
    }
	// your code goes here
	return 0;
}

https://www.codechef.com/problems/STUDVOTE?tab=statement

What’s wrong in the solution

@abhinav_singh1
for test case
1
2 1
1 1
your output :- 1
correct answer would be 0.

1 Like