WA in MAXPR...plz help

I’m getting WA in MAXPR repeatedly…

Plz tell me where my algorithm is wrong…

And for test cases it is giving WRONG ANSWER…

Soln link:-- http://www.codechef.com/viewsolution/4107416

Soln link in ideone :-- http://ideone.com/lXU7Dv

Thnx in Advance…

EDIT:–
FINALLY GOT AC

1
100
23 21 32 4 54 65 2 2 1 5 6 77 77 54 1 3 6 97 95 22 44 63 23 21 32 4 54 65 2 2 1 5 6 77 77 54 1 3 6 97 95 22 44 63 34 54 12 54 88 68 23 21 32 4 54 65 2 2 1 5 6 77 77 54 1 3 6 97 95 22 44 63 23 21 32 4 54 65 2 2 1 5 6 77 77 54 1 3 6 97 95 22 44 63 34 54 12 54 88 68 take this…why havent you used modulous in your loops int dp and at last pow(2,n) would overflow…you havent handled overflows properly
ans is 976360319
but your code is giving -291172004

2 Likes

Corrected as u said and got the same answer…
But still getting WA…

soln link :-- http://www.codechef.com/viewsolution/4107666
Thnx for ur help…

Finally got AC…
Got to learn about some modular airthmetic…
Thnx for ur help…