WA for droughts,pls help

using the approach given in the editorial (DRGHTS-Editorial - editorial - CodeChef Discuss)i worked on code and works well for gievn test cases (and few complex test cases of mine too), but gives WA when i submit it,can somebody please point out the problem in my code.heres my code OJM2VC - Online C++0x Compiler & Debugging Tool - Ideone.com

Its giving wrong answer for:

5 4

1 0 0 1 1

1 2

2 4

4 5

5 3

Its outputting 3 5 instead of 3 4.

http://ideone.com

1 Like

Always give link to the question atleast.

hey, thanx for your valuable inputs, i am working on it.

thanx to ur input hk02, i worked on the code and changed it to work correctly now it outputs correct result but gives
TLE, i’ll appreciate it if u could suggest me how should i optimize the code to avoid TLE…heres my code awrIaJ - Online C++0x Compiler & Debugging Tool - Ideone.com
thanx for ur time

sorry my bad…heres it is…DRGHTS Problem - CodeChef