SELFDEF - Editorial

Setter: Nandeesh Gupta
Tester: Abhinav Sharma, Manan Grover
Editorialist: Lavish Gupta

Cakewalk

if-condition

PROBLEM:

After the phenomenal success of the 36th Chamber of Shaolin, San Te has decided to start 37th Chamber of Shaolin. The aim this time is to equip women with shaolin self-defence techniques.

The only condition for a woman to be eligible for the special training is that she must be between 10 and 60 years of age, inclusive of both 10 and 60.

Given the ages of N women in his village, please help San Te find out how many of them are eligible for the special training.

EXPLANATION:

The problem is intended to test whether the contestants can correctly use the if-statements (or conditional statements in general).

Given the age of one of the women, we can find out if she is eligible for the special training or not. If Yes, we can increment our answer by 1.

Now we iterate over the ages of all the women to find out the total number of women eligible for the special training.

TIME COMPLEXITY:

O(N) for each test case.

SOLUTION:

Editorialist's Solution
``````#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll ,ll>
using namespace std ;
const ll z = 998244353 ;

int main()
{

int t ;
cin >> t ;
while(t--)
{
int n;
cin >> n ;
int ans = 0 ;

for(int i = 0 ; i < n ; i++)
{
int u ;
cin >> u ;
if(u >= 10 && u <= 60)
ans++ ;
}
cout << ans << endl ;
}

return 0;
}
``````