TopCoder problem "VeryInterestingMovie" used in TCHS SRM 55 (Division I Level One)



Problem Statement

    A teacher wants to take his students to see a movie at the theater. The only problem is that the students talk a lot, so the teacher doesn't want any two students in the same row to sit in adjacent seats.

You are given a String[] seats which contains information about which seats are available for purchase. Character j of element i of seats is 'Y' if the j-th seat in row i is available, or 'N' otherwise. Return the maximum number of students who can watch the movie.
 

Definition

    
Class:VeryInterestingMovie
Method:maximumPupils
Parameters:String[]
Returns:int
Method signature:int maximumPupils(String[] seats)
(be sure your method is public)
    
 

Constraints

-seats will contain between 1 and 50 elements, inclusive.

-Each element of seats will contain between 1 and 50 characters, inclusive.

-All elements of seats will be of equal length.

-Each element of seats will contain only 'Y' or 'N' characters.

 

Examples

0)
    
{"YY","YY","YY"}
Returns: 3
Only one student can sit in each row.
1)
    
{"NNNNN","NNNNN","NNNNN","NNNNN","NNNNN"}
Returns: 0
No places are available.
2)
    
{"YYYYYYN","YYYYNYY","NYYYNYY","NYYYYYN","YYYYYYN","NYYNYNY","YYYYYYY"}
Returns: 22

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=9955

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13524&pm=9955

Writer:

Gluk

Testers:

PabloGilberto , Olexiy , ivan_metelsky

Problem categories:

Simple Math