更好的阅读体验
D. Yet Another Yet Another Task
题目描述
Alice and Bob are playing yet another card game. This time the rules are the following. There are n n n cards lying in a row in front of them. The i i i-th card has value a i a_i ai.
First, Alice chooses a non-empty consecutive segment of cards [ l ; r ] ( l ≤ r ) [l;r] (l\le r) [l;r](l≤r). After that Bob removes a single card j j j from that segment ( l ≤ j ≤ r l\le j \le r l≤j≤r). The score of the game is the total value of the remaining cards on the segment ( a l + a l + 1 + ⋯ + a j − 1 + a j + 1 + ⋯ + a r − 1 + a r a_l+a_{l+1} + \dots +a_{j-1} + a_{j+1} + \dots + a_{r-1} + a_r al+a