WA for droughts,pls help


using the approach given in the editorial (http://discuss.codechef.com/questions/38496/drghts-editorial)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 http://ideone.com/OJM2VC

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.


1 Like

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

Always give link to the question atleast.

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 http://ideone.com/awrIaJ
thanx for ur time

sorry my bad…heres it is…http://www.codechef.com/problems/DRGHTS