#P3337. [ZJOI2013] 防守战线
[ZJOI2013] 防守战线
Description
The frontline can be viewed as a sequence of length . We need to build towers on this sequence to defend against enemy troops. Building a tower at position costs , and any number of towers can be built at the same position, with costs added together. There are intervals , and within the -th interval, at least towers must be built. Find the minimum cost.
Input Format
The first line contains two numbers .
The next line contains numbers, describing the array.
The next lines each contain three numbers , describing an interval.
Output Format
Output a single line with one number: the minimum cost.
5 3
1 5 6 3 4
2 3 1
1 5 4
3 5 2
11
Hint
Sample explanation:
Build towers at position , one tower at position , and one tower at position . The cost is .
Constraints:
- For of the testdata, , .
- For of the testdata (including the above), all are .
- For of the testdata (including the above), , .
- For of the testdata, , , , and all other values are .
Translated by ChatGPT 5
京公网安备 11011102002149号