report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Delete operation - MarisaOJ: Marisa Online Judge

Delete operation

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers. You can perform the following operation at most $k$ times: - Pick 2 indices $l, r$ such that $1 \le l \le r \le n$, assign $0$ to each element $A_l, A_{l + 1}, ...,A_r$. Find the maximum possible sum of elements in $A$ after performing some operations? ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ integers $A_i$. ### Output - Print the maximum possible sum of $A$. ### Constraints - $1 \le n, k \le 5000$. - $|A_i| \le 10^9$. ### Example Input: ``` 4 1 1 -3 1 -10 ``` Output: ``` 1 ```
Introduction to Dynamic Programming (Part two)
Sake game
Coins
Coins 2
Game on array
Longest increasing subsequence 2
Convolution
Regular bracket sequence
Faulty addition
Weird bank
Delete operation
Palindromize
Color ribbon
Unique subsequences
Unique subsequences 2
Cow exhibition
Knapsack 3
Compressing array
Regular bracket sequence 2
Maximum path 3
Concating substring
Soil
Stacking boxes
String transformation
Palindromic quadruple
Finding teammates
Topic
Dynamic Programming
Rating 1400
Solution (1) Solution