5 4 3 5 1 2 10 40 20 60 50
210 Takahashi can achieve his objective as follows. * Choose $(l,r)=(1,5)$. Consume $\max(10,40,20,60,50)=60$ MP, and the staminas of the monsters are $(3,2,4,0,1)$. * Choose $(l,r)=(1,5)$. Consume $\max(10,40,20,60,50)=60$ MP, and the staminas of the monsters are $(2,1,3,-1,0)$. * Choose $(l,r)=(1,3)$. Consume $\max(10,40,20)=40$ MP, and the staminas of the monsters are $(1,0,2,-1,0)$. * Choose $(l,r)=(1,1)$. Consume $\max(10)=10$ MP, and the staminas of the monsters are $(0,0,2,-1,0)$. * Choose $(l,r)=(3,3)$. Consume $\max(20)=20$ MP, and the staminas of the monsters are $(0,0,1,-1,0)$. * Choose $(l,r)=(3,3)$. Consume $\max(20)=20$ MP, and the staminas of the monsters are $(0,0,0,-1,0)$. Here, he consumes a total of $60+60+40+10+20+20=210$ MP, which is the minimum possible.
1 1000000000 1000000000
1000000000000000000
10 522 4575 6426 9445 8772 81 3447 629 3497 7202 7775 4325 3982 4784 8417 2156 1932 5902 5728 8537
77917796
{
"problem": {
"name": "Ex - Monster",
"description": {
"content": "There are $N$ monsters along a number line. At the coordinate $i$ $(1\\leq i\\leq N)$ is a monster with a stamina of $A_i$. Additionally, at the coordinate $i$, there is a permanent shield of a streng",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc275_h"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There are $N$ monsters along a number line. At the coordinate $i$ $(1\\leq i\\leq N)$ is a monster with a stamina of $A_i$. \nAdditionally, at the coordinate $i$, there is a permanent shield of a streng...",
"is_translate": false,
"language": "English"
}
]
}