Company: Infosys sp role_26april
Difficulty: medium
In satellite signal processing, a stream of N data packets is received. Each packet i is classified into a category A[i] (ranging from 0 to C-1 ) and carries a specific signal weight W[i] representing its data density. A monitoring window [l, r] (the contiguous range of packets from index l to r ) is considered frequency-balanced if there is at least one category that appears in strictly more than half of the packets in that window. In other words, some category is a strict majority in the window. Find the maximum total weight (the sum of W[i] for all packets in the window) over all possible frequency -balanced windows. Input Format The first line contains a integer, N , denoting the total number of data packets. The second line contains a integer, C , denoting the total number of possible categories. Each line i of the N subsequent lines (where 0 ≤ i < N ) contains a integer, A[i] . Each line i of the N subsequent lines (where 0 ≤ i < N ) contains a integer, W[i] . Constra