[SEERC 2020] Archeologists

Luogu
IDLGP10736
Time3000ms
Memory512MB
DifficultyP6
贪心2020ICPCSEERC
你在玩一个寻宝类游戏,一共有 $n$ 个格子,编号为 $1 \sim n$,你每在 $i$ 号格子上下挖一层便会获得 $p_i$ 的价值,其中你需要保证每个格子相邻的两个格子都与其下挖的深度的差值不超过 $1$(注意此时 $1$ 和 $n$ 号点最多只能挖一层),请最大化总价值。 ## Input 第一行一个整数 $n\ (1 \leq n \leq 2.5 \times 10^5)$。 接下来一行 $n$ 个整数 $p_i\ (-10^6 \leq p_i \leq 10^6)$。 ## Output 输出最大价值。 [samples] ## Note 样例一解释: ![](https://cdn.luogu.com.cn/upload/image_hosting/jalyemdz.png)
Samples
Input #1
5
1 3 -4 2 1
Output #1
8
Input #2
4
1 1 -2 3
Output #2
5
Input #3
5
-1 -3 0 -5 -4
Output #3
0
API Response (JSON)
{
  "problem": {
    "name": "[SEERC 2020] Archeologists",
    "description": {
      "content": "你在玩一个寻宝类游戏,一共有 $n$ 个格子,编号为 $1 \\sim n$,你每在 $i$ 号格子上下挖一层便会获得 $p_i$ 的价值,其中你需要保证每个格子相邻的两个格子都与其下挖的深度的差值不超过 $1$(注意此时 $1$ 和 $n$ 号点最多只能挖一层),请最大化总价值。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P6"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10736"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "你在玩一个寻宝类游戏,一共有 $n$ 个格子,编号为 $1 \\sim n$,你每在 $i$ 号格子上下挖一层便会获得 $p_i$ 的价值,其中你需要保证每个格子相邻的两个格子都与其下挖的深度的差值不超过 $1$(注意此时 $1$ 和 $n$ 号点最多只能挖一层),请最大化总价值。\n\n## Input\n\n第一行一个整数 $n\\ (1 \\leq n \\leq 2.5 \\times 10^5)$。\n\n接...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments