You just came up with a problem to put on a rated contest! You've invited testers to test the problem, numbered from to , each of whom will attempt the problem and then vote either YES
or NO
. In order for the problem to be approved, a majority (strictly greater than half) of the testers must vote YES
. You already know how each tester will vote, but it may not be a majority.
However, you have a few tricks up your sleeve. In one move, you can select an interval . Let be the number of testers in that interval that vote YES
. Then, you can change the vote of tester to YES
. Determine if you are able to force a majority of the testers to vote YES
after making any number (possibly zero) of moves.
Constraints
Input Specification
The first line of input contains a single integer , the number of testers.
The second line contains a string of length consisting of Y
or N
characters. The character is Y
if the tester votes YES
and N
if the tester votes NO
.
Output Specification
Output YES
if you're able to force a majority of the testers to vote YES
.
Otherwise, output NO
.
Sample Input 1
4
YNNY
Sample Output 1
YES
Explanation for Sample 1
On the first move, we can select the interval to get and force tester to vote YES
.
The votes are now YYNY
, which is a majority.
Sample Input 2
5
NYNNN
Sample Output 2
NO
Explanation for Sample 2
There are no sequences of moves that result in a majority of the testers voting YES
.
Sample Input 3
3
YYN
Sample Output 3
YES
Explanation for Sample 3
A majority of the testers already vote YES
, so no moves are necessary.
Comments