problem : http://www.codechef.com/COOK39/problems/PPLUCKY My idea :
If I get digit 4 , then this 4 will not effect any 7 before this position.
If currently i get 7 and i have one or more unused 4, then i will have a pair 47 in any iteration . Now, I have to find in which iteration i will get this pair.
I can get this iteration number greedly and can get total number of pair erased before this position using RMQ.
My implementations :
http://pastebin.com/7RBu4Gs5 1. http://www.codechef.com/viewsolution/2863273 2. http://www.codechef.com/viewsolution/2859710
No idea , why WA . Need critical input ........
Thanks in advance