Andrash and Stipendium

PROBLEM :

Andrash study in Uzhland National University. Now is the time of exam results. Andrash similar to other students, hopes that this scores in the exam could fetch him a scholarship/stipendium for his studies.

There are following simple rules to receive stipendium:

University follows 5 point grading system. In an exam, a student can receive any score from 2 to 5. 2 is called an F grade, meaning that student has failed that exam.
Student should not have fail any of the exams.
Student must obtain a full score in some of his/her exams to show that he/she is excellent in some of the subjects.
He/She must have a grade point average not less than 4.0
You are given information regarding the exams and how Andrash performed in those. Can you help him figure out whether he will receive the stipendium or not!!

Input

The first line of input contains a single integer T denoting the number of test cases. This will be followed by T test cases.

The first line of each test case contains an integer N denoting the number of examinations.

The next line of each test case contains N space separated integers denoting Andrash's score for each exam.

Output

For each of the T test cases, output a single line - "Yes" (without quotes) if Andrash will receive stipendium, or "No" (without quotes) - otherwise.

Constraints and Subtasks

1 = T = 40
Let A[i] denote Andrash's score for i-th exam
Subtask #1: 20 points

1 = N = 100
2 = A[i] = 5
Subtask #2: 20 points

1 = N = 105
3 = A[i] = 5
Subtask #3: 60 points

1 = N = 105
2 = A[i] = 5
Example

Input:
2
5
3 5 4 4 3
5
3 4 4 4 5

Output:
No
Yes

Explanation

Example case 1. Student's average grade point score is 3.8 which makes him/her unqualified for obtaining the stipend.

Example case 2. Student satisfies all the criteria for getting stipend.

--------------------------------------------------------------------------------
SIMPLE c++ IMPLEMENTATION :
--------------------------------------------------------------------------------

#include<iostream>
using namespace std ;

int main()
{
int t,no,i,flag,full ;
float sum ;

cin>>t ;
while(t--)
{
cin>>no ;

int a[no] ;
flag=1 ;

for(i=0;i<no;i++)
cin>>a[i] ;

sum=0 ;
full=0 ;

for(i=0;i<no;i++)
{
sum=sum+a[i] ;
if(a[i]==5)
full++ ;
if(a[i]==2)
flag=0 ;
}
sum=sum/no ;

if(sum<4)
flag=0 ;

if(full==0)
flag=0 ;


if(flag==0)
cout<<"No" ;
else
cout<<"Yes" ;

cout<<endl ;
}
}

---------------------------------------------------------------------------------

Comments

Popular posts from this blog

Count ways to N'th Stair(Order does not matter)

Replace all ‘0’ with ‘5’ in an input Integer

Chocolate Distribution Problem

Remove characters from the first string which are present in the second string

Primality Test ( CodeChef Problem code: PRB01 )