| 3 | using namespace std; |
| 4 | |
| 5 | void solve(int num, int index){ |
| 6 | int arr[num]; |
| 7 | int number,count = 0; |
| 8 | for(int i=0;i<num;i++){ // the loop takes the number as input and also check if the index is equal to the one passed |
| 9 | cin >> arr[i]; |
| 10 | if((i+1)==index){ |
| 11 | number = arr[i]; // if the index is equal to the one passed, then it is assigned to a variable for comparison |
| 12 | } |
| 13 | } |
| 14 | for(int i=0;i<num;i++){ |
| 15 | if(arr[i]>=number && arr[i]>0){ // checks if the number at the index is greater or equal to the number of the contestant at the given index |
| 16 | count++; // if the condition satisfies, then the count is incremented |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | cout << count; // the count is then printed (the answer) |
| 21 | |
| 22 | } |
| 23 | |
| 24 | int main(){ |
| 25 | ios::sync_with_stdio(0); |