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

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

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://codeforces.com/contest/1742/submission/203843549

can you send me the correct code?

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

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

You can find tutorial on this link.

»
15 месяцев назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится
fixed code
»
15 месяцев назад, # |
  Проголосовать: нравится +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 < a_2 < ... < 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.