[信息与未来 2014] 取数

Luogu
IDLGB4135
Time1000ms
Memory512MB
DifficultyP3
动态规划 DP2014江苏信息与未来
有 $n$ 个数排成一排,从 $n$ 个数中任取若干个数,取数规则为每次取相邻的 $2$ 个数,不能取 $1$ 个,也不能取多于 $2$ 个连续的数,找一种取法,使取到数的和为最大。 ## Input 第一行一个整数,表示 $n$; 第二行有 $n$ 个整数,表示 $x_1,x_2,\cdots,x_n$。 ## Output 一个整数,即合理取法中最大的和。 [samples] ## Note $2\le n\le 10^5,1\le x_i\le 10^9$。
Samples
Input #1
6
13 2 17 14 8 16
Output #1
43
API Response (JSON)
{
  "problem": {
    "name": "[信息与未来 2014] 取数",
    "description": {
      "content": "有 $n$ 个数排成一排,从 $n$ 个数中任取若干个数,取数规则为每次取相邻的 $2$ 个数,不能取 $1$ 个,也不能取多于 $2$ 个连续的数,找一种取法,使取到数的和为最大。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB4135"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "有 $n$ 个数排成一排,从 $n$ 个数中任取若干个数,取数规则为每次取相邻的 $2$ 个数,不能取 $1$ 个,也不能取多于 $2$ 个连续的数,找一种取法,使取到数的和为最大。\n\n## Input\n\n第一行一个整数,表示 $n$;\n第二行有 $n$ 个整数,表示 $x_1,x_2,\\cdots,x_n$。\n\n## Output\n\n一个整数,即合理取法中最大的和。\n\n[samples]\n\n##...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments