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 :
No idea , why WA . Need critical input ........
Thanks in advance