MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / solve

Function solve

Codeforces_problems/Next Round/solution.cpp:5–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5void 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
24int main(){
25 ios::sync_with_stdio(0);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected