Problem
You are given an integer sequence of length N and another value X. You have to find a contiguous subsequence of the given sequence such that the sum is greater or equal to
X. And you have to find that segment with minimal length.
Sample Input
|
|
Sample Output
|
|
Solution
題目描述:
找一段長度最小,且該區間總和大於等於指定 X。
題目解法:
離散化後,利用掃描線的思路進行維護。
利用前綴和 SUM[i],查找小於等於 SUM[i] - X 的最大值。
隨後更新 SUM[i] 位置的值 i。
|
|