Now I get it, I was misinterpreting question all this time. Actually after finish of each round, lead is not the difference between points of that round. But the lead is difference between the points achieved through all rounds including current round - Lakpa Tashi Bhutia
I made a DP state similar to LCS where dp[i][j] indicates the length of the best subsequence possible using A[0..j] and B[0..j]. Then for each state I select an element from A[0..j-1] and try to find its complement in B using a map. See the code for more detail.
However this fails on all test cases except two giving me a depressing 20/100.
What is wrong with my DP? What other approaches are possible? This approach (if you assume all elements in B are distinct) becomes O(N^3 log N). If we don't assume all elements are distinct, we get ~= the same time (I guess?). I did not get any TLEs on the judge, and the worst time was 0.103s so that's a good sign.
Yesterday night I went to the nearby cyber cafe to attend the first programming contest of my life. But I had to complete the contest in 1/3 time as the cyber cafe was about to get closed by 9:00 p.m.(Don't have PC at home, this I am writing from my school lab.).
Made a new codechef account for the same purpose, settled myself on a computer with 20 mins to go for the contest.
The wait ended and and the problems flashed on the screen.
Started the first problem with full excitement. The problem was set by Udit Sanghi, and the problem statement started with something bad about schools(What else did you expected) which on one go I understood it is unsolvable for me, atleast in the given time constraints. Went for the another problem "Ant in a Box", Ahhh this was the problem I came for, but the genius inside me thought that following formulas are same