# PROBLEM LINK: Contest Page | CodeChef

Author: Setter’s name

Tester: Tester’s name

Editorialist: Editorialist’s name

DIFFICULTY: EASY

Nill

# PROBLEM:

There are N theatres in your town, each premiering a different movie. Each movie has a rating. You wish to watch the movie with available tickets. If tickets are available for more than 1 movie, then you would go for the one with the highest rating.

You should find whether you were able to watch a good movie, a bad movie, or Housefull ( no tickets available) A movie is good if it has a rating of more than 5. If not, then it is bad.

# QUICK EXPLANATION:

Iterate through every movie, and check if tickets are available.

If tickets are available, check if it’s rating is greater than the current maximum rating.

# EXPLANATION:

Let’s shorten the question

To watch a movie, you should follow 2 conditions

1. It should have available tickets.
2. If available, it should have the highest rating.

So first we should iterate through every movie, and check if tickets are available.

If tickets are available, check if it’s rating is greater than the current maximum rating. If yes, it should be the current maximum element.

We can print the output based on the maximum element we found using if else condition

That is:

• If it is greater than 5, then print “Good”.
• If it is equal or less, then print “Bad”.
• If the array is empty (No movies with available tickets), then print “Housefull”.

# SOLUTIONS:

Setter's Solution

using namespace std;

void solve(){

int n;

cin>>n;

vector ar;

int max=-1;

for(int i=0;i<n;i++)

{

int d;

string s;

cin>>d>>s;

if(s.compare(“Yes”)==0)

{

if(max<d)

max=d;

}

}

if(max==-1)

cout<<“Housefull”;

else if(max>5)

cout<<“Good”;

else

}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

solve();

return 0;

}

Tester's Solution

Same Person

Editorialist's Solution

Same Person