[PA 2022] Ornitolog 2

Luogu
IDLGP9253
Time1000ms
Memory512MB
DifficultyP2
2022PA(波兰)
**题目译自 [PA 2022](https://sio2.mimuw.edu.pl/c/pa-2022-1/dashboard/) Runda 1 [Ornitolog 2](https://sio2.mimuw.edu.pl/c/pa-2022-1/p/orn/)** 交替鹡鸰(*Motacilla alterna*)是鹡鸰属的一种鸟类。它因其独特的鸟鸣而与众不同,这种鸟的鸟鸣中,连续的音高交替地增加和减少。例如,如果我们用整数来表示音高,那么,鸟鸣可以是 $[2, 1, 3]$ 和 $[4, 5, -6, -5]$,但不能是 $[1, 2, 3, 2]$ 或 $[6, 5, 5, 4]$。为了记录这种迷人的生物,鸟类学家 Byteasar 将他的录音笔留在森林中数天。他现在想知道录到的声音是否与鹡鸰的鸟鸣相似。 写一个程序,给定音高序列,确定最少将音高序列中多少个整数改成 $[-10^9,10^9]$ 区间内的任意整数,才能使得这个序列成为交替鹡鸰鸟鸣的音高序列。 ## Input 第一行一个整数 $n$,表示这个音高序列的长度。 第二行 $n$ 个整数 $a_1,a_2,\ldots,a_n$,表示这个音高序列。 ## Output 输出最少要修改多少整数才能使这个序列成为交替鹡鸰鸟鸣的音高序列。 [samples] ## Note 对于 $100\%$ 的数据,满足: $3\le n\le 5 \times 10^4, -10^6\le a_i\le 10^6$。
Samples
Input #1
5
4 1 3 3 1
Output #1
1
Input #2
4
-1000000 -1000000 -1000000 -1000000
Output #2
2
API Response (JSON)
{
  "problem": {
    "name": "[PA 2022] Ornitolog 2",
    "description": {
      "content": "**题目译自 [PA 2022](https://sio2.mimuw.edu.pl/c/pa-2022-1/dashboard/) Runda 1 [Ornitolog 2](https://sio2.mimuw.edu.pl/c/pa-2022-1/p/orn/)** 交替鹡鸰(*Motacilla alterna*)是鹡鸰属的一种鸟类。它因其独特的鸟鸣而与众不同,这种鸟的鸟鸣中,连续的音高",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9253"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "**题目译自 [PA 2022](https://sio2.mimuw.edu.pl/c/pa-2022-1/dashboard/) Runda 1 [Ornitolog 2](https://sio2.mimuw.edu.pl/c/pa-2022-1/p/orn/)**\n\n交替鹡鸰(*Motacilla alterna*)是鹡鸰属的一种鸟类。它因其独特的鸟鸣而与众不同,这种鸟的鸟鸣中,连续的音高...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments