DMOPC '20 Contest 3 P1 - Present Checking

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Amy bought her N friends each a gift, and wrapped them all. However, in her haste, she may have labelled them wrong! She labelled all of the gifts with integers L_i, but she may have made a mistake and forgotten a friend, or given one friend multiple gifts. Can you help her?

Constraints

1 \le L_i \le N \le 10^6

Subtask 1 [6/15]

1 \le N \le 2000

Subtask 2 [9/15]

No additional constraints.

Input Specification

The first line will contain N, the number of friends Amy has.

The next line will contain N space-separated integers L_i, the labels on the gifts.

Output Specification

If there are no duplicate labels and each friend from 1 to N received a gift, output YES.

Otherwise, output NO.

Sample Input 1

4
4 2 3 1

Sample Output 1

YES

Explanation for Sample Output 1

Each friend received a gift, and no friend received more than one gift, so Amy labelled her gifts correctly.

Sample Input 2

10
1 3 2 4 5 8 6 3 7 10

Sample Output 2

NO

Explanation for Sample Output 2

Note that friend number 9 did not receive a gift.


Comments

There are no comments at the moment.