Editorial for DMOPC '18 Contest 2 P4 - Damage Output
Submitting an official solution before solving the problem yourself is a bannable offence.
For the first subtask, brute-force all subarrays and their sums.
For the second subtask, check all subarrays and use a prefix sum to calculate their sums.
For the third subtask, we do a two-pointer walk. Keep a left and right pointer, initially both set to the starting index. If the subarray currently described by the two pointers has a sum less than , move the right pointer. Otherwise, move the left pointer. Since all the elements are non-negative, this will find the smallest subarray with sum at least .