시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 95 | 45 | 19 | 36.538% |
After returning from the Wonderland, Alice needs to improve her scientific skills in this current digital world. Alice decides to participate the ACM-ICPC Asia Nha Trang Regional Contest 2016 to evaluate her actual performance. Her most favorite problem in the contest is following.
Given an array of positive integers A = a1, a2,…, an, a subarray Ai,j of A is a sequence of
continuous elements in A, i.e., Ai,j = ai, ai+1,…, aj (where 1 ≤ i ≤ j ≤ n). The weight of Ai,j is the sum of all its elements,
Given an integer m, your task is to find the maximum weight subarray of \(A\) that contains only one m as the minimum element. You can assume that A always contains at least one element with value m.
The input consists of several datasets. The first line of the input contains the number of datasets, which is a positive number and is not greater than 20. The following lines describe the datasets.
Each dataset is described by the following lines:
For each dataset, write out on one line the found maximum weight.
1 6 2 1 3 2 6 2 4
12
ICPC > Regionals > Asia Pacific > Vietnam > 2016 Nha Trang Regional Contest A번