3018. Maximum Number of Removal Queries That Can Be Processed I
ArrayDynamic Programming
Hints
Hint 1
Think of dynamic programming.
Hint 2
The definition of
dp is a little unusual. Try to think more.Hint 3
Let
dp[l][r] be the maximum number of queries we can process if we want a[l], a[l + 1], ..., a[r - 1] not to be removed after processing dp[l][r] queries.Hint 4
So
dp[0][n] = 0 since we can not remove anything.Hint 5
The answer would be
max(dp[i][i]).Preparing judge…