Longest Constrained Subsequence

All submissions for this problem are available.
You are given two arrays of length N. Array A = $A$_{1}, $A$_{2}, ..., $A$_{N}. Array L = $L$_{1}, $L$_{2}, ..., $L$_{N}. For every k such that $1 \leq k \leq N$, you have to find the length of the longest possible subsequence in the first k elements of array A such that if $A$_{j} immediately follows $A$_{i} in the subsequence, then $A$_{j}$A$_{i}$ \leq L$_{j} Please note that the input is __encrypted__. Read Input section for information. __It is advised to use fast I/O methods__ ###Input:  First line contains a single integer $N$, the no of elements of the arrays.  The ith of the next N lines contains two values, $A’$_{i} and $L’$_{i}, the encrypted values of $A$_{i} and $L$_{i}. Suppose that the (i1)th output was $Ans$_{i1}, then $A$_{i} = $Ans$_{i1} $XOR$ $A’$_{i}, and $L$_{i} = $Ans$_{i1} $XOR$ $L’$_{i}, where $XOR$ denotes the bitwise xor operator. Assume $Ans$_{0} = 0. ###Output: Output N integers, each in a new line, the ith of which should be the length of the longest possible subsequence uptil $A$_{i}. ###Constraints  $1 \leq N \leq 10^5$  $1 \leq A$_{i}$ \leq 10^9$  $1 \leq L$_{i}$ \leq 10^9$  $0 \leq A'$_{i}$ \leq 2*10^9$  $0 \leq L'$_{i}$ \leq 2*10^9$ ###Sample Input: 5 1 1 3 0 6 1 5 2 4 0 ###Sample Output: 1 2 3 3 4 ###EXPLANATION: The decrypted query is: 5 1 1 2 1 4 3 6 1 7 3 The largest possible subsequences are: 1) {1} 2) {1,2} 3) {1,2.4} 4) {1,2,4} 5) {1,2,4,7}Author:  kr_abhinav 
Tags  kr_abhinav 
Date Added:  2042018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 