Interval Addition
Time limit4sMemory limit2048 MB
Given an array of up to 23 values, find the fewest operations that add a real number to a contiguous interval to make every element zero.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Dynamic programming, Prefix sum
- Solved
- No attempts yet
Problem
You are given an array of integers. You can perform operations on this array. In a single operation, you can add any real number to some consecutive interval of .
Determine the minimum number of operations that have to be performed to make all elements of equal to .
Input
The first line contains an integer ().
The second line contains the array ().
Output
Print a line with a single integer: the minimum number of operations needed.