Woburn Challenge 2017-18 Round 3 - Junior Division
Problem 2: Certified Fresh
A new science fiction psychological thriller action-comedy film, The Codefather, is being released this weekend! You'd love to go see it, but you'll first need to convince your friends that it'll be good. Fortunately, trusted movie review websites such as Rotten Tomatoes exist for this purpose!
Following its release in theatres, The Codefather will receive a series of N (1 ≤ N ≤ 100) reviews from certified Rotten Tomatoes critics, one after another. The i-th review will either be positive (if Ri = "
P") or negative (if Ri = "
At any given point in time after its first review, each movie on Rotten Tomatoes is considered to have a certain Tomatometer score. This score is a real number, computed as the number of positive reviews received so far divided by the total number of reviews received so far.
You're concerned that The Codefather's final Tomatometer score may end up not being too high, as general audiences may not grasp its subtle competitive programming-driven writing. However, if you keep refreshing its Rotten Tomatoes page as new reviews come in, maybe you can catch a point in time at which it has a higher score, and take a screenshot of it to show to your friends! Determine the maximum Tomatometer score which The Codefather will reach at any point after its first review.
Your answer must have at most most 10−5 absolute or relative error compared to the judge's answer to be considered correct.
The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single character, Ri, for i = 1..N.
Output a single real number, the maximum Tomatometer score achieved by The Codefather.
7 N P N P P N P
After the first 5 reviews, The Codefather has received 3 positive reviews and 2 negative ones, resulting in a Tomatometer score of 3 / 5 = 0.6. This is the largest score that it achieves at any point in time.
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 23, 2018
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3