{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e小青蛙最近迷上了消消乐这个游戏\u003c/p\u003e\n\u003cimg height \u003d \"200\" width \u003d \"200\" src \u003d https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u\u003d3345341152,889768288\u0026fm\u003d26\u0026gp\u003d0.jpg\u003e\u003c/img\u003e\n\u003cp\u003e游戏共有两种操作:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e操作一,将其中一列的格子全部消除\u003c/li\u003e\n\u003cli\u003e操作二,选择一个连续的区间,在这个区间里,不存在某一列为空(已经被消除)。然后让这个区间内的每一列消除一格\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e两种的操作花费都是1\u003c/p\u003e\n\u003cp\u003e现在给出游戏最初始的样子,请你计算通过这个游戏的最小花费\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e第一行 n 表示游戏中的列数 (1 \u003c\u003d n \u003c\u003d 5000)\u003c/p\u003e\n\u003cp\u003e第二行 n 个数字Ai 表示每一列的初始高度 (1 \u003c\u003d Ai \u003c\u003d 10\u003csup\u003e 9\u003c/suo\u003e)\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e一行 表示最小的花费\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cp\u003eInput\u003c/p\u003e\n\u003cp\u003e5\u003c/p\u003e\n\u003cp\u003e2 2 3 3 3 \u003c/p\u003e\n\u003cp\u003eOutput\u003c/p\u003e\n\u003cp\u003e3\u003c/p\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003e对于样例,你可以选择,每一列都用操作一,那么花费就是5\u003c/p\u003e\n\u003cp\u003e也可以选择对区间[1, 5] 使用 2 次操作二,变成 0 0 1 1 1 然后再使用 1 次操作二,变成 0 0 0 0 0 ,花费是3\u003c/p\u003e"}}]}