#K65592. Maximum Subarray Sum with Checkpoint

    ID: 32231 Type: Default 1000ms 256MiB

Maximum Subarray Sum with Checkpoint

Maximum Subarray Sum with Checkpoint

You are given an array of n integers and a checkpoint value x. Your task is to find the maximum sum of any contiguous subarray that must include at least one occurrence of x. If no subarray contains x, output "NOT POSSIBLE".

More formally, for an array \(a_1, a_2, \dots, a_n\) and a checkpoint value \(x\), find the maximum value of \(\sum_{i=l}^{r} a_i\) over all \(1 \le l \le r \le n\) such that there exists an index \(j\) with \(l \le j \le r\) and \(a_j = x\). If there is no valid subarray, output "NOT POSSIBLE".

inputFormat

The first line contains an integer T representing the number of test cases. For each test case, the first line contains two integers n and x, where n is the number of elements in the array and x is the checkpoint value. The second line contains n integers separated by spaces representing the array.

outputFormat

For each test case, output the maximum contiguous subarray sum that includes at least one occurrence of x. If no such subarray exists, output "NOT POSSIBLE". Each answer should be printed on a new line.

## sample
3
5 3
1 2 -3 4 3
4 2
1 1 1 1
4 10
-1 -2 10 -3
7

NOT POSSIBLE 10

</p>