PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000198. Tổng đoạn nhỏ nhất có độ dài thuộc khoảng (Minimum Subarray Sum With Length Bounds)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng đoạn nhỏ nhất có độ dài thuộc khoảng (Minimum Subarray Sum With Length Bounds)
Minimum Subarray Sum With Length Bounds
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers and two length bounds , find the minimum sum of any consecutive interval satisfying and . Empty intervals are forbidden. A valid interval always exists since .
Input
The first line contains . The second contains exactly integers .
Output
Print the minimum sum.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Example 1
Input
5 2 3
3 -5 2 -4 6
Output
-7
Explanation
Interval [2,4] sums to -7. Length-two sums are -2,-3,-2,2; length-three sums are 0,-7,4.
Example 2
Input
3 1 2
4 1 3
Output
1
Explanation
Interval [2,2] sums to 1, the minimum among eligible intervals.