KIỂM TRA HOÁN VỊ

PDF

Submit solution

Points: 10.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem source:
Sưu tầm
Problem types
Allowed languages
C, C++, Java, Pascal, Python, Scratch, TEXT

Cho dãy số nguyên ~P=(p_1,p_2,…,p_n )~, hãy xác định P có phải hoán vị của dãy số (1,2,…,n) hay không?

Dữ liệu:

Dòng 1 chứa số nguyên dương ~n≤10^6~
Dòng 2 chứa n số nguyên ~p_1,p_2,…,p_n~ cách nhau bởi dấu cách. ~(∀i:|a_i|≤10^9)~

Kết quả:

Ghi ra từ YES nếu dãy P là hoán vị của dãy số (1,2,…,n), từ NO nếu P không phải hoán vị của dãy số (1,2,…,n)

Sample Input:

6
1 3 6 5 4 2

Sample Output:

YES

Sample Input:

7
1 3 6 5 3 2 7

Sample Output:

NO

Sample Input:

5
0 0 0 0 0

Sample Output:

NO

Comments

Please read the guidelines before commenting.


There are no comments at the moment.