Feedback for AVGFLEX problem

Learning course: Level up from 1* to 2*
Problem Link: CodeChef: Practical coding for everyone

Feedback

There is an issue in the question in “is greater than the number of students scoring greater than” part. The question says “greater than” but the system accepts the code that implements “greater than or equal to” instead.

@b_suvonov
Can u send the code which u claim will fail but gets accepted.??

@dpcoder_007
Of course!

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

bool intCompare(int a, int b){
    return (a<b);
}

int check(int mid, int scores[], int N){
    int lessScores{0}, higherScores{0};
    for(int i=0; i<mid; i++){
        if(scores[i]<=scores[mid]){
            lessScores++;
        }
        else{
            higherScores++;
        }
    }
    for(int i=mid+1; i<N; i++){
        if(scores[i]>scores[mid]){
            higherScores++;
        }
        else{
            lessScores++;
        }
    }
    return (higherScores<=lessScores);
}

int main() {
    int T{0};
    cin >> T;
    for(int i=0; i<T; i++){
        int N, mid{0}, count{0};
        cin >> N;
        int scores[N]={0};
        for(int j=0; j<N; j++){
            cin >> scores[j];
        }
        sort(scores, scores+N, intCompare);
        mid = (N-1)/2;
        while(check(mid, scores, N)==0){
            mid++;
        }
        
        for(int j=0; j<mid; j++){
            if(scores[j]== scores[mid]){
                count++;
            }
        }
        
        cout << N-mid +count << '\n';
    }
	return 0;
}