codeforces educational round question doubt

this is the question and here is my solution http://codeforces.com/contest/620/submission/15504012
after coreecting the solution i got this http://ideone.com/RIqSws but it is showing it wrong . help me to find out the reason

@rahulsup, you just need to make sure that your first partition starts from 1 on the left side and final partition ends with n on the right side. -1 exist only when there are no duplicate elements in the array. Otherwise just find the partitions by greedy method and apply the conditions mentioned before.

Here is my Accepted Solution for the same.

1 Like

If you feel your question is answered, upvote it and mark it as answered. For any other queries, you can ask in the comments section.

@likecs thanks a lot. can you tell me what is my mistake which i should correct.

Your code is similar to mine. Just add one more line regarding the 2nd condition that whenever you are having a valid solution, the last partition’s second element should be n. (see my code for details)

1 Like

Can anyone tell, why my code is giving a wrong answer for test case 13 for the CODEFORCES problem-> SEREJA AND BRACKETS

http://codeforces.com/contest/380/problem/C

Here is my code:::

(SORRY I DONT HAVE ENOUGH KARMAS TO POST MY OWN QUESTION… SO POSTING IT HERE LOL :slight_smile: )