[PA 2018] Nowy kontrakt

Luogu
IDLGP9080
Time2000ms
Memory256MB
Difficulty
2018PA(波兰)
**题目译自 [PA 2018](https://sio2.mimuw.edu.pl/c/pa-2018-1/dashboard/) Runda 2 [Nowy kontrakt](https://sio2.mimuw.edu.pl/c/pa-2018-1/p/kon/)** 。 给定一个长度为 $N$ 的正整数序列 $a$ ,你需要对序列内数末尾添加数字的方法使序列**严格单调递增**,你的目标是最小化添加数字的次数。 在数 $a$ 后添加数字 $t$ 即为: $a \gets a \times 10 + t$ ,其中 $t \in \{0,1,2,3,4,5,6,7,8,9\}$ ## Input 第一行一个整数 $N$ 表示序列长度。 第 $2$ 行至 $N+1$ 行每行一个数,第 $i$ 行表示序列中第 $i-1$ 个数。 ## Output 一行一个整数,表示最小操作次数。 [samples] ## Note #### 样例 1 解释 对第 $2$ 个数字和第 $3$ 个数字分别添加一个数字,即 $a_2 \gets a_2 \times 10 + 7$ , $a_3 \gets a_3 \times 10 + 3$ 。 得到的新序列为 $(8,57,133)$ ,是一个严格单调递增序列。操作次数为 $2$ ,还有其他的操作次数为 $2$ 的方法,但是不存在操作次数为 $1$ 的方法。 ------------ #### 数据范围 **本题采用捆绑测试** 对于 $100\%$ 的数据: - $1 \le N \le 200000$ - $1 \le a_i \le 10^9$
Samples
Input #1
3
8
5
13
Output #1
2
API Response (JSON)
{
  "problem": {
    "name": "[PA 2018] Nowy kontrakt",
    "description": {
      "content": "**题目译自 [PA 2018](https://sio2.mimuw.edu.pl/c/pa-2018-1/dashboard/) Runda 2 [Nowy kontrakt](https://sio2.mimuw.edu.pl/c/pa-2018-1/p/kon/)** 。 给定一个长度为 $N$ 的正整数序列 $a$ ,你需要对序列内数末尾添加数字的方法使序列**严格单调递增**,你的目",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP9080"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "**题目译自 [PA 2018](https://sio2.mimuw.edu.pl/c/pa-2018-1/dashboard/) Runda 2 [Nowy kontrakt](https://sio2.mimuw.edu.pl/c/pa-2018-1/p/kon/)** 。\n\n给定一个长度为 $N$ 的正整数序列 $a$ ,你需要对序列内数末尾添加数字的方法使序列**严格单调递增**,你的目...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments