SGSELECT-Editorial

PROBLEM LINK

Author: Pranjal Tank
Tester: Shreyansh Narayan
Editorialist: Ayush Kumar Singh

DIFFICULTY:

CakeWalk

PREREQUISITES:

Array

Problem:

The town is sinking in debts, and people are willing to play any game for it. You are Hwang Jun-Ho, a police detective who got to know that someone is collecting all these people in debt. You have the list of all the people who have large amounts of dues from various people. However, to know if they will participate in the games, you need to know the eligibility criteria of the games. Luck seems to favor you and you have received the qualification rules for the same. Find them out, before it’s too late.

You are given an array of debts of NN participants in Won, which is the currency of South Korea.

The qualification will be done on the following condition:

  • If the debt is greater than 50 Won.
  • If the debt is less than or equal to 2000 Won.

EXPLANATION:

Consider any i^{th} Participant if his debt is greater than 50 (>50) and it’s less than or equal to 2000 (<=2000) then we can say that the Participant is qualified for the next game.

TIME COMPLEXITY:

The time complexity for the above problem will be O(N) as we are iterating the array of size n and checking whether the participant is qualified or not.

SOLUTION:

Editorialist's Solution

#include
using namespace std;
int main (){

int n;
cin>>n;

int a[n];
int qualified=0;

for(int i=0;i<n;i++){
    cin>>a[i];

    if(a[i]>50 && a[i]<=2000){
        qualified++;
    }
}

cout<<qualified<<endl;
return 0;

}