Invn1234's blog

By Invn1234, history, 15 months ago, In English

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?

  • Vote: I like it
  • -14
  • Vote: I do not like it

| Write comment?
»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

You can find tutorial on this link.

»
15 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it
fixed code
»
15 months ago, # |
  Vote: I like it +1 Vote: I do not like it

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.