logo AlgoBeat OnlineJudge
登录 注册

#212629. [UOI 2023] An Array and Range Additions

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Given an array of integers of length .

You can modify the array using the addition operation. To apply the addition operation, you need to perform three sequential actions:

  • Choose any integer .
  • Choose any subarray of the array.
  • Add to each element of the chosen subarray (perform the assignment operation for ).

Find the minimum number of addition operations required to make all elements of the array pairwise distinct.

输入格式

The first line contains a single integer () --- the length of the array.

The second line contains integers () --- the elements of the array.

输出格式

Output a single integer --- the minimum number of addition operations required to make all elements of the array pairwise distinct.

样例

样例输入 1

3
1 2 3

样例输出 1

0

样例输入 2

5
2 3 2 3 2

样例输出 2

2

样例输入 3

9
2 3 1 1 3 2 1 3 3

样例输出 3

2

数据范围与提示

In the first example, all elements of the array are pairwise distinct.

In the second example, after applying two \textit{addition operations} with parameters , , and , , , the array becomes equal to .

In the third example, after applying two \textit{addition operations} with parameters , , and , , , the array becomes equal to .

Scoring

  • ( points): all elements of the array are equal to .
  • ( points): for ; for .
  • ( points): .
  • ( points): .
  • ( points): .
  • ( points): for .
  • ( points): no additional constraints.