Блог пользователя Invn1234

Автор Invn1234, история, 3 года назад, По-английски

It is supposed to do this:

input:

3

4

1 1 1 1

5

8 7 1 3 4

1

5

output:

NO

YES

YES

my code:

https://mirror.codeforces.com/contest/1742/submission/203843549

can you send me the correct code?

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

You can find tutorial on this link.

»
3 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится
fixed code
»
3 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

If $$$n = 1$$$, the answer is obviously YES. Otherwise, you just need to sort the array in any order (ascending or descending) and loop from 0 to n-1, check if there exists a[i] = a[i+1], then the answer is NO, because $$$a_1 \lt a_2 \lt ... \lt a_n$$$ cannot be hold if there exist two equal elements. In other word, the answer is YES if and only if all elements in array are unique.