#C11368. Majority Ones Contiguous Subsequence
Majority Ones Contiguous Subsequence
Majority Ones Contiguous Subsequence
You are given a binary string s of length n. Your task is to determine whether the string itself has a majority of ones. In other words, check if the number of '1' characters is strictly greater than \(\lfloor n/2 \rfloor\). If this condition holds, output YES
; otherwise, output NO
.
Note: Even though the problem statement mentions a contiguous subsequence, the intended solution is to verify the condition for the entire string. Hence, you only need to consider the complete string.
For example, if \( n=5 \) and \( s = "11001" \), there are 3 ones and 2 zeros. Since \( 3 > \lfloor5/2\rfloor = 2 \), the answer is YES
.
inputFormat
The input is read from standard input and consists of two lines. The first line contains an integer \( n \), representing the length of the binary string. The second line contains the binary string \( s \) composed only of characters '0' and '1'.
outputFormat
Output a single line to standard output containing either YES
if the number of ones in the string is strictly greater than \( \lfloor n/2 \rfloor \), or NO
otherwise.
5
11001
YES