#abc205b. B - Permutation Check

B - Permutation Check

Score : 200200 points

问题描述

给定一个包含 NN 个整数的序列 A=(A1,A2,,AN)A = (A_1, A_2, \dots, A_N),这些整数都在 11NN(包括两端点)之间。

请判断序列 AA 是否为 (1,2,,N)(1, 2, \dots, N) 的一个排列。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a sequence of NN integers between 11 and NN (inclusive): A=(A1,A2,,AN)A = (A_1, A_2, \dots, A_N).

Determine whether AA is a permutation of (1,2,,N)(1, 2, \dots, N).

Constraints

  • 1N1031 \leq N \leq 10^3
  • 1AiN1 \leq A_i \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

Output

If AA is a permutation of (1,2,,N)(1, 2, \dots, N), print Yes; otherwise, print No.

Sample Input 1

5
3 1 2 4 5

Sample Output 1

Yes

(3,1,2,4,5)(3, 1, 2, 4, 5) is a permutation of (1,2,3,4,5)(1, 2, 3, 4, 5), so we should print Yes.

Sample Input 2

6
3 1 4 1 5 2

Sample Output 2

No

(3,1,4,1,5,2)(3, 1, 4, 1, 5, 2) is not a permutation of (1,2,3,4,5,6)(1, 2, 3, 4, 5, 6), so we should print No.

Sample Input 3

3
1 2 3

Sample Output 3

Yes

Sample Input 4

1
1

Sample Output 4

Yes

update @ 2024/3/10 09:18:08